Django error “You are trying to add a non-nullable field to submission without a default


You are trying to add a non-nullable field ‘owner’ to submission without a default; we can’t do that (the database needs something to populate existing rows).
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows)
2) Quit, and let me add a default in models.py

This is a common error in Django. Django will prevent a non-null field to be used except a default value is provided, alternatively the field is declared nullable.

To fix issue, you can either do one of the following:

user = models.ForeignKey(User, related_name='User', null=True)

or use the default user:

user = models.ForeignKey(User, related_name='User', default=<have your default user id here>)


About Matthias 33 Articles
I am a Software Engineer from Houston, TX who love to write codes that brings great ideas to live. In my professional life, I have created software for different industries including Oil & Gas, Finance, Service Provider, Cloud Computing and Embedded Systems. When not writting codes, i enjoy travelling, good music and photography. You can reach me at me@matthiasomisore.com.

1 Comment

  1. I must say it was hard to find your page in google.

    You write awesome content but you should rank your page higher in search engines.

    If you don’t know how to do it search on youtube: how to rank a website Marcel’s way

Leave a Reply

Your email address will not be published.


*