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

Django models

From the course: Learning Django

Start my 1-month free trial

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…

Contents