Previous Page Next Page

Understanding Models

Django implements a Python class, django.db.models.Model, to define data models that will be used in a website. A data model is a set of definitions that define the attributes of objects that will be stored in the database. When you build your website, you create a subclass of the Model class and add Field members to that class to define specific data. Django's model interface provides a full-featured selection of field types that make it easy to define each model.

The models you define in your project are synchronized to an SQL database backend as tables. Django also provides a nice database interface that lets you access data in the database from views and templates. We will discuss models more in Hour 3, "Adding Models and Objects to Your Website," and Hour 5, "Using Data from the Database in Views."

Previous Page Next Page