A model is the single, definitive source of information about your data: it contains the essential fields and behaviors of what you are storing, and each model generally maps to a single database table. Each model is a Python class that subclasses django.db.models.Model, and each class attribute represents a database field that maps to a column; Django then provides an automatically-generated database-access API. A Person model with first_name = models.CharField(max_length=30) produces a varchar(30) column — CharField and its subclasses require max_length, which sets the VARCHAR size. By default the table name is derived from model metadata by combining the app name with the lowercased model name (myapp_person), and an auto-incrementing id primary key is added automatically, with its type set per app via AppConfig.default_auto_field or globally via the DEFAULT_AUTO_FIELD setting; both defaults can be overridden. The generated SQL is tailored to whichever database backend your settings file selects — PostgreSQL, for example, emits an identity-column id. Scope: Django. Reviewed October 4, 2026.
Models as the single source of truth
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- docs.djangoproject.com
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.