[Solved]-Django: When to run makemigrations?

27👍

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.

👤nik_m

3👍

First of all,

./manage makemigrations

will create (migration_number).py files in your app migrations folders. These lines of code are nothing but statements which help in creating actual fields in your respective database similar to SQL statements.

In order to execute the migration which was created using the previous command, we will run the following command,

./manage.py migrate

On migrate your new model fields will be reflected in database if there are no errors

Leave a comment