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:
Now let's see what exactly they are doing with our database.
- First we create a new model class in models.py
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 models.py file.
The corresponding SQL command after creating your class models in models.py and using makemigrations will be
and finally, we run this command:
migrate: What will happen after this command?
It will create the table in the database using the commands which have been generated by makemigrations.
Top comments (2)
good job bro
Homie G