#Python #Shorts
In the last video we explored how we can define Django models inside models.py file to represent tables and columns in the database. But right now we don't even have a database because we never created it.
Whenever you're using an ORM, the process of creating the database and applying changes to it, or just applying additional changes if it was already created, is known as a database migration.
The migration consists of two steps. First, creating an actual migration, which we can do by running "python manage.py makemigrations". It will create a file with the instructions of what changes to apply. If you get "No changes detected", try running "python manage.py makemigrations yourappname".
And the second step is the actual migration, which is done by running "python manage.py migrate". This will create the database and all the tables and columns defined in our models.py file.
And if you look into your Django project folder now, you should see a new sqlite database being created.
-------------------------------------------------------------------------------------
Links:
Blog: https://evgenyurubkov.com
Twitter: / evgenyurubkov
Instagram: / evgenyurubkov
Youtube: / @codevev
Watch video Django Database Migration - Python Web Development! online without registration, duration hours minute second in high quality. This video was added by user codevev 13 July 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,40 once and liked it 6 people.