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