Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我编写了一个模型,该模型的字段可以为空白,不为空,并且不是必需的。当我创建并保存模型的实例而不包含与此类字段对应的数据时,django 仍然使用空字符串值保存此类字段。我的问题是,有什么办法可以避免这种情况吗?
default=None在您的字段定义中设置: foo = models.CharField(..., default=None).
default=None
foo = models.CharField(..., default=None)