DEV Community

Cover image for Django: makemigrations and migrate

Django: makemigrations and migrate

banji220 profile image Banji ・1 min read

In this post, I'm trying to explain what makemigrations and migrate commands can do in Django.

We have these 2 commands in Django to create SQL commands:

Alt Text

Now let's see what exactly they are doing with our database.

  1. First we create a new model class in

Alt Text

Then in command-line:
Alt Text

makemigrate: What will happen after this command?
It will generate the SQL command to create the table corresponding to each class you made in the file.

The corresponding SQL command after creating your class models in and using makemigrations will be

Alt Text

and finally, we run this command:
Alt Text
migrate: What will happen after this command?
It will create the table in the database using the commands which have been generated by makemigrations.

Discussion (2)

Editor guide
amirdarx profile image

good job bro

banji220 profile image