Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Python

Django Models

Define database tables as Python classes with Django’s ORM.

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

Leave a reply

Your email address will not be published. Required fields are marked *