Back End

Django and the data underneath it: models, the ORM, REST APIs, authentication, background work, and the databases that store the result.
Author

Benedict Thekkel

This is the largest site in the collection and the most opinionated, because it is written from actually shipping Django applications rather than from surveying the field. Django and Django REST Framework are assumed throughout.

The shape is roughly the order you meet the problems. Model your data, query it without generating a thousand queries, expose it as an API, decide who is allowed to call it, move the slow parts into the background, and store it somewhere that survives a restart. The database folder covers that last part independently, because the choice outlives any one application.


Getting Started with Django

Page Covers
Django Basics The foundation, and by far the longest page here at 150 cells
Django Stack The pieces and how they fit
DjangoX A preconfigured starting point
Django Templates Starter templates, from barebones to full SaaS platforms

Models and Data

Page Covers
Model Design Getting the schema right, which is the decision everything else inherits
Saving Objects How writes actually go through
JSONField Storing and querying JSON in the database when a rigid schema does not fit
Migrations Changing the schema without losing data
Validators Enforcing conditions before a value reaches the database, across models, forms, and serializers

Querying the ORM

Five pages on the same subject, because this is where Django applications get slow.

Page Covers
Query Filters How the QuerySet API turns Pythonic queries into SQL
QuerySets The object you are actually manipulating
Query Math Aggregations, arithmetic, and window functions, all without dropping to raw SQL
Managers and QuerySets Encapsulating query logic where it belongs instead of scattering it through views
django-filter Filtering a queryset from form input, wired into class-based views and DRF
Indexing and Caching The two levers for query optimisation

REST APIs

Page Covers
REST API Standard The architectural style itself, before any framework
DRF Basics What the toolkit gives you
DRF Quickstart The fastest path to a working API
DRF Tutorial The longer worked version
Serialization Turning models into JSON and back
Views The request handlers in between
Nested Routers Routing resources that belong to other resources
DRF Spectacular Generating OpenAPI 3.0 schemas, which is what feeds Swagger UI, ReDoc, and Postman
DataTables Server-Side Delegating filtering, sorting, and pagination from the browser table to DRF

Authentication, Permissions, and Secrets

Page Covers
Authentication DRF’s authentication system
User Models Modelling users, which is worth getting right before the first migration
Allauth Third-party accounts and social login
Permissions Controlling who can reach which endpoint
Permission Rules Object-level permissions expressed as plain Python functions, via django-rules
Permission Types Access control models for SaaS specifically, and how to choose between them
Security Secure coding practice, audits, and the tooling that finds problems
Secrets Keeping credentials out of the repository

Admin and Forms

Page Covers
Django Admin Customising the admin from the basics to the advanced techniques
Admin Unfold Modernising the admin interface without rebuilding it
Forms The built-in form layer
Crispy Forms Rendering them without hand-writing the markup
npm in Django Managing front-end dependencies such as Bootstrap from inside a Django project

Background Work and Real Time

Page Covers
django-q A task queue and scheduler built for Django, simpler than the alternative
Celery The distributed alternative, for when django-q is not enough
Channels WebSockets and async protocols, which is what makes chat, notifications, and live updates possible
MQTT The publish/subscribe broker, for IoT devices and sensors feeding the backend

Operations

Page Covers
Custom Commands Writing your own manage.py subcommands
Django Commands The built-in ones
Testing pytest against a Django project
Backups django-dbbackup for database and media, to local or cloud storage
Email Configuring and sending mail
Import and Export Moving data in and out as CSV, Excel, or JSON, from the admin or programmatically
PDF Generation WeasyPrint rendering HTML and CSS into invoices, reports, and receipts
Constance Admin-editable settings stored in the database, which gives you feature flags and thresholds without a redeploy
Recovery Metrics Setup The project-specific setup notes

Databases

Independent of Django, because the choice outlives the application.

Page Covers
SQL The language itself: querying, inserting, updating, deleting
PostgreSQL Database structure and practice, for the default choice
PostgreSQL Setup Getting it running
PostgreSQL Extensions What extensions are, how they work, and a catalogue grouped by use case
TimescaleDB Time-series inside Postgres, driven from Django
MySQL and MariaDB The other major open-source relational option
SQLite Serverless and zero-configuration, for embedded use and development
DuckDB The analytical counterpart, aimed at data and ML work rather than transactions
Redis In-memory store used as cache, broker, and database, with the data structures that make it flexible
InfluxDB The time-series backend, covered at length

Not Covered Yet

  • No FastAPI or Flask. Django is the only web framework here, so there is no comparison against the async-first alternatives.
  • Nothing on deployment. Getting the application onto a server is covered in Web Development and IaaS, not here, so this site stops at the code.
  • No API versioning or deprecation strategy, despite the depth of DRF coverage.
  • Nothing on rate limiting or throttling as a subject of its own.
  • No database replication, sharding, or connection pooling. The database pages stop before scale.
  • QuerySets, Indexing and Caching, and Email are thin at four to five cells, and indexing in particular deserves more given how often it is the answer.
  • Django/03_2_Permission _Types.ipynb has a stray space in its filename, which is why its URL looks wrong.

Back to top