How to make a Foreign Key field non-nullable with a default
Non-nullable foreign keys require the ID of the default object. Learn how to create a custom migration to create a default.
Non-nullable foreign keys require the ID of the default object. Learn how to create a custom migration to create a default.
Understanding how migrations work in Django is key to preventing hard-to-fix errors.
If you want to create a migration but want to assign a custom value to each of the existing rows, you can add custom Python to your migration.