【发布时间】:2021-08-21 19:32:10
【问题描述】:
我想清空以下多对多字段中的所有内容(weekday_with_class):
all_existing_class.weekday_with_class = None
这里是models.py:
weekday_with_class = models.ManyToManyField('Weekday', blank=True, related_name='weekday_with_class')
但是,如果我执行上面的代码,我会得到这个错误:
Direct assignment to the forward side of a many-to-many set is prohibited. Use weekday_with_class.set() instead.
对于一个实例,如何基本上使我的weekday_with_class 为空?谢谢,如果您需要更多信息,请发表评论。
【问题讨论】:
标签: python django django-models many-to-many django-errors