Django:如何将字段设置为NULL?


Answers:


124

分配None


1
如此简单,但在Django文档中不容易找到。他们需要可以通过Google搜索的常见问题解答。
uchuugaka

2
不适用于ManyToManyFieldTypeError: 'NoneType' object is not iterable
CoderGuy123 '16

1
@Deleet ManyToManyField在数据库中表示为另一个表,在该表中可以存在或不存在关系(它将是m2m表中的另一行)。没有字段可分配NULL。请参阅clear或remove关键字以删除所有m2m关系。docs.djangoproject.com/en/1.11/ref/models/relations/...
Jose_mr
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.