我在用户模型上创建了一个新字段。
blocked_users = models.ManyToManyField('self', verbose_name=_('blocked users'),
symmetrical=False,
related_name='blocked_by',
blank=True)
所以,我想要被阻止的用户:
In [18]: User.objects.first().blocked_users.all()
Out[18]: <UserQuerySet [<User: admin>, <User: test@mail.com>, <User: i_uglev>, <User: denisdvornikov6697>]
现在,我清楚并再试一次:
In [21]: User.objects.first().blocked_users.clear()
In [22]: User.objects.first().blocked_users.all()
Out[22]: <UserQuerySet [<User: admin>, <User: test@mail.com>, <User: i_uglev>, <User: denisdvornikov6697>]>
我尝试从django-admin执行此操作并获得相同的结果。怎么了?