I have a model in my Django app that requires a new BooleanField
column to be added. This column should never be null - instead, I'd like all the existing entries to set this field to False
.
How do I do that? If I just add the new field and set default = False
, it'll cause an OperationalError: no such column
error.
You need to use Django's migrations, which will allow you to add the field to the database.
In short, you make the change to your model, create a migration with manage.py makemigrations
, and then run it with manage.py migrate
.