我正在使用userena,并将以下代码行添加到我的models.py中
zipcode = models.IntegerField(_('zipcode'),
max_length=5)
在我点击注册表单上的提交按钮后,我得到了以下错误:
IntegrityError at /accounts/signup/
NOT NULL constraint failed: accounts_myprofile.zipcode
我的问题是这个错误是什么意思,这与Userena有关吗?
发布于 2014-09-22 06:17:15
您必须创建一个迁移,在该迁移中,您将为新字段指定默认值,因为您不希望它为空。如果不需要null,只需添加null=True
并创建并运行迁移。
发布于 2015-09-08 20:47:15
如果邮政编码字段不是必填字段,则添加null=True和blank=True,然后运行makemigrations和迁移命令以成功反映数据库中的更改。
发布于 2021-03-25 04:48:51
在models.py中,您应该将null=True
添加到ZipCode域。
https://stackoverflow.com/questions/25964312
复制相似问题