Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: When to run makemigrations?

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 ?

like image 609
Cody Avatar asked Mar 25 '17 13:03

Cody


People also ask

When should you run Makemigrations?

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.

What is the use of Makemigrations in Django?

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.


1 Answers

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.

like image 130
nik_m Avatar answered Sep 21 '22 05:09

nik_m