Django Cheat Sheet
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. The reference material consulted while preparing these pages is listed in the section bibliography. |
A single-page, colour-coded summary of the Django essentials, written against Django 6.1 (6.1.1), with Django 5.2 LTS
(5.2.17) differences flagged by version, Python 3.12-3.14 and PostgreSQL 15 or newer (versions verified 2026-10-03) — the project layout and manage.py commands, settings including STORAGES, models and fields (choices,
db_default, GeneratedField, constraints, indexes and composite primary keys), relationships and every on_delete
option including the 6.1 database-level DB_* ones, Meta, model inheritance, managers and migrations, the ORM
(lookups, F and Q, aggregation, Subquery and window functions, select_related, prefetch_related and the 6.1
fetch modes, transactions and on_commit), URLs and views (converters, namespaces, reverse, shortcuts, decorators
and the generic class-based view map with its key hooks), a request/response-cycle strip with the default
MIDDLEWARE order, templates (key tags and filters, partials, {% querystring %}, custom tags), forms (validation
order, model forms, formsets, rendering), the admin, authentication and security settings (POST logout,
LoginRequiredMiddleware, custom user model, hashers, CSRF, CSP, HSTS and check --deploy), services (cache, email
and MAILERS, tasks, signals, logging, i18n and time zones, pagination), async and Channels, Django REST framework and
Django Ninja, testing, deployment servers, and a strip of what changed since older tutorials — handy for quick
memorization or as a downloadable PDF desk reference.
For the full explanation, every option, and additional examples, see the dedicated pages:
Start here — Django.
Foundations — Introduction & Architecture, Getting Started, Project Structure & Apps, Settings & Configuration, and Management Commands & Shell.
Models and the ORM — Models & Fields, Relationships, Model Inheritance & the Meta API, Migrations, Making Queries, Aggregation, Expressions & Functions, Managers & Custom QuerySets, Constraints, Indexes & Composite Keys, Transactions, Raw SQL & Multiple Databases, Query Optimization & Fetch Modes, PostgreSQL & Database Backends, and Fixtures, Serialization & Initial Data.
HTTP — Request/Response Cycle, URLs & Routing, Function-Based Views & Shortcuts, Class-Based Views, Generic Views, Middleware, Sessions, Cookies, Messages & Signing, File Uploads & Storage, and Responses, Streaming, CSV & PDF.
Templates — Templates, Template Partials & htmx, Custom Template Tags & Filters, and Static Files & Front-End Assets.
Admin — Admin Site and Admin Customization.
Auth and security — Authentication, Custom User Model & Backends, Permissions & Authorization, Passwords, Security, and Content Security Policy.
Application services — Caching, Email, Tasks Framework, Celery Integration, Signals, Logging & Error Reporting, Internationalization & Translation, Localization & Time Zones, Pagination, and System Checks.
Contrib apps — ContentTypes & Generic Relations, Sites, Sitemaps & Feeds, Flatpages, Redirects & Humanize, and GeoDjango.
Async and real-time — Async Support and Channels & WebSockets.
Web APIs — Django REST Framework, Django Ninja, and GraphQL with Django.
Testing — Testing and pytest, Factories & Browser Tests.
Production — Deployment, Docker & Kubernetes, and Performance & Optimization.
Beyond the basics — What’s Changed & Upgrading, Reusable Apps & Third-Party Packages, and Best Practices.
References
The PDF summarizes the official documentation; each source is cited in full on the page listed above that covers it, and in the section bibliography.