Skip to content
Justice Tech School

Models

A model is a Python class that describes a database table. Each attribute is a column. Django creates the SQL for you.

Example
# blog/models.py
from django.db import models

class Post(models.Model):
    title = models.CharField(max_length=200)
    body = models.TextField()
    created = models.DateTimeField(auto_now_add=True)

Exercise

Base class of models.

class Post(models.):

Quiz Test

What does a model class represent?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.