【发布时间】:2021-09-20 20:16:02
【问题描述】:
我正在尝试使用信号从组中添加和删除用户,但我不明白我在哪里做错了。这是我的代码:
@receiver(post_save,sender=settings.AUTH_USER_MODEL)
def group(sender,instance,created,**kwargs):
group = Group.objects.get(name='myauthors')
if instance.is_blog_author == True:
instance.groups.add(group)
elif instance.is_blog_author == False:
instance.groups.remove(group)
【问题讨论】:
-
有什么问题?你有任何错误吗?
-
@BrianD 没有。我没有收到任何错误
标签: python python-3.x django