Django Models — a practical guide to Django models with clear examples you can reuse in real projects.
Python Tutorial Series (74/95). Prefer one article? Read the complete Python tutorial.
Short description
Models describe fields and behavior. Migrate after changes to update the database schema.
Post model
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=200)
body = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title