#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
Смотрите видео Django Database Migration - Python Web Development! онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь codevev 13 Июль 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 2,408 раз и оно понравилось 62 людям.