So you added a few fields on a model. You’re happy about the new model fields and you’re excited to deploy it to your server.
You throw the following into your commandline.
Despite your giddiness that people will be working on your new models and you’re going to impress your boss and your friends, you receive the following message:
Oh, no! Now what do you do?
The reason you are getting this prompt is because, your database isn’t empty. The model that you updated with new fields, already has records saved.
Therefore, Django needs to add defaults to those records that already exist.
How do you add a default to your model? How do you add a default to your models?
Let’s say your new model looks like this:
How do you add a default to this new field? Quite simply:
Then, when you call ‘makemigrations’ again:
Simple! You now have a new field and you got rid of that annoying prompt!