[Django]-Django default foreign key value for users

0👍

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)

0👍

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)!

👤null

Leave a comment