Search⌘ K

Models in Django

Explore how to use Django models to define database tables, fields, and relationships including primary and foreign keys. Understand creating models as Python classes and connecting to databases like SQLite within your Django projects.

Introduction to Models

An essential part of any website is the ability to accept information from a user, input it into a database, retrieve information from a database, and use the retrieved information to generate content for the user. We can use Models to incorporate a database into a Django Project.

Models define the structure of the data stored in a database, including the field types, possibly their maximum size or default values, etc. A Model in Django is a python class that generally maps to a single database table. Django already comes equipped with SQLite. So, we will be using SQLite for our examples in this course. However, Django can also connect to a variety of other SQL engine backends, including PostgreSQL and MySQL.

Using a different

...