您好,我收到此错误是因为我的 additional user info model 中有一个字段(user = models.OneToOneField(User)
) 我在注册时没有填写(因为我想让用户稍后填写)。
除了在数据库中允许空字段外,我想知道是否有任何方法可以解决这个问题?
干杯
最佳答案
尝试
user = models.OneToOneField(User, null=True, blank=True)
然后重新创建您的数据库。 您可以在 https://docs.djangoproject.com/en/1.4/ref/models/fields/#null 上找到更多信息
否则你可以使用代理模型:
class UserExtraInfo(User):
#here your extra fields
在这种情况下,您不需要与 User 同时创建 UserExtraInfo 实例。 在 https://docs.djangoproject.com/en/1.4/topics/db/models/#model-inheritance 上阅读更多内容
关于python - IntegrityError at/***/(1048, "Column ' ** *' cannot be null") 在 python django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12036400/