(sender, instance, action, *args, **kwargs)
给某个用户添加多个标签
给某个用户添加多个标签
给某个用户添加多个标签
def user_tag_changed(sender, instance, action, *args, **kwargs):
    """给某个用户添加多个标签"""
    if kwargs["reverse"] and not getattr(instance, "_tag_local", False):
        tags = UserTag.objects.filter(_id__in=kwargs["pk_set"]).all()
        tag_ids = [tag.id for tag in tags]
        client = instance.app.client.tag
        for tag in tags:
            if action == "pre_add":
                client.tag_user(tag.id, instance.openid)
            elif action == "pre_remove":
                client.untag_user(tag.id, instance.openid)
def user_tag_changed ( sender , instance , action , * args , * * kwargs ) : if kwargs [ "reverse" ] and not getattr ( instance , "_tag_local" , False ) : tags = UserTag . objects . filter ( _id__in = kwargs [ "pk_set" ] ) . all ( ) tag_ids = [ tag . id for tag in tags ] client = instance . app . client . tag for tag in tags : if action == "pre_add" : client . tag_user ( tag . id , instance . openid ) elif action == "pre_remove" : client . untag_user ( tag . id , instance . openid )