Using model inheritance and encounting by non-nullable field error
In order to inherit from Questions
in TypeFive
, Django needs to add a relation from TypeFive
to Questions
. For all records in TypeFive
that might already be in the database.
Django now doesn't know which question it should relate TopFive
to. This is what the migrate command asks you for. You have a few options, but they greatly depend on your use case and whether you are in early development or if there is a production database where this migration has to run later.
I'm in early development and running it on localhost, so iI don't care about my records. Now, what should I do?
In this case you haven't much to worry about, when migrate
asks you type 1
and then press enter
. Now add a primary key
of a Questions
instance that is in your database and then hit enter
again.
Django now relates all TypeFive
instances that are currently in the database to this question, so you might have to clean that up afterwards (e.g. by editing the TypeFive
in Django admin).