django default foreign key value for users

混江龙づ霸主 提交于 2019-12-05 13:05:13

If you want it to be possible to have an empty value for author, you need to define the ForeignKey with null=True. You'll probably want blank=True as well, as that controls the validation in Django forms.

author = models.ForeignKey(User, null=True, blank=True)

Ended up taking the easy route and totally resetting the product table, and migrating from scratch which worked. Not sure i've learnt anything (other than how to reset an app)!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!