Django: Getting Started Transcripts
Chapter: Django ORM and Databases
Lecture: Initializing the database

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Alright, you've got two new models, author and book. Now, it's time to ask Django to put them in the database.
0:08 Let me just go to the execution window here. The command you need to run first is make migrations.
0:14 This will examine all the model files and see if anything has changed since the last time you ran that command.
0:20 As you've added two new models, it will pick that up. I'll get into the details of this a bit later
0:25 But for now just understand this is how Django creates scripts that make the database changes for you. With the migration files made,
0:39 the next step is to actually run the underlying scripts. When I ran that command, Django looked into the database where it tracks the state
0:51 of all objects and checked the current version of all the migration scripts. It would have found no version number for the catalog app,
0:59 seen the new catalog migration script and then run it. The migration table in the database is then updated with the catalog migration scripts,
1:08 version number. This way, Django can compare the state of all your model files against the state of the actual database.
1:15 With the migration complete, I'm going to open up a bash terminal and show you your brand new models in action.


Talk Python's Mastodon Michael Kennedy's Mastodon