From the course: Learning Django
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Django models
- [Instructor] Models create the data layer of a given Django app. This means that they define the structure of our data and how it will be stored in the database. We will also use our models to leverage Django's ORM, or object-relational mapper, when querying data from the database. The models.py file contains the set of models for its Django app. A model is a class that inherits from django.db.models.Model, and it defines fields as class attributes. As a rough analogy, we can conceptualize models as spreadsheets. Each model is a table in a spreadsheet, while each field of the model is a column for that spreadsheet table. Once our database is populated with data, we can think of each record in the database as a row in the spreadsheet. For our adoptions app our models will support a small set of requirements for an animal shelter adoption system. We'll need to store the pets available for adoption, each with a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Models, routing, views, and templates3m 55s
-
(Locked)
Django models1m 19s
-
(Locked)
Django fields3m 46s
-
(Locked)
Implement model and fields5m 24s
-
(Locked)
Django migrations6m 5s
-
(Locked)
Import CSV data6m 24s
-
(Locked)
Work with the Django admin7m 18s
-
(Locked)
Query data with the Django ORM6m 42s
-
-
-
-