In addition to adding/deleting/modifying field to model, Django also detects changes when I add or modify methods to the model.
So my question is should I run makemigrations
every time I change or add a new method in models ?
When to run makemigrations. You'll want to run python manage.py makemigrations w henever you make a change to a model, even if it is updating the description on a field. Adding or updating functions inside of a model does not need a migration, but you can still run makemigrations just in case.
makemigrations is responsible for packaging up your model changes into individual migration files - analogous to commits - and migrate is responsible for applying those to your database.
When you add/change model methods, then you don't need to run ./manage makemigrations
and ./manage.py migrate
.
But whenever you edit your model fields (adding a new one, changing an existing one or altering any of the arguments it takes) then you should always run migrations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With