Django: Getting Started Transcripts
Chapter: Introducing the Django Web Framework
Lecture: Database models
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
If your website is going to be more than just static pages, you're likely to need to manage some data, Djangos models, abstract away a database.
0:10
To create a model, you define classes with fields that define what should be contained
0:14
in the object and then Django maps this to tables in the database. Several different databases are supported out of the box,
0:23
and even more are available as 3rd party plug ins. As your project changes, your models may change.
0:30
This means that the underlying database has to change as well. That can get complicated.
0:35
Django provides a migration mechanism that helps you modify the database as your code evolves.
0:41
Models are also able to specify relationships between each other.
0:46
This maps to things like foreign keys in the database and of course storing isn't enough you have to get the data back out.
0:54
Django provides a query manager for each class. You define, allowing you to execute queries on the database all the while mapping it to your objects.