Django Database Migration - Python Web Development!

Publié le: 13 juillet 2021
sur la chaîne: codevev
2,408
62

#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  


Sur cette page du site, vous pouvez voir la vidéo en ligne Django Database Migration - Python Web Development! durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur codevev 13 juillet 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 2,408 fois et il a aimé 62 téléspectateurs. Bon visionnage!