Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. Getting Django Running Properly in Production
Python & Django

Getting Django Running Properly in Production

Deploying a Django application: debug off, secrets from the environment, static files served properly, migrations in deployment, supervision and logging.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

Debug off, secrets from the environment, static files served properly, migrations run as part of deployment, and a process supervisor keeping everything alive.

The settings that matter

  1. Debug off, without exception, in production
  2. Allowed hosts set correctly
  3. Secret key from the environment, unique per environment
  4. Database credentials from the environment
  5. Secure cookie and HTTPS settings enabled
Debug left on in production exposes your settings, your database queries and your stack traces to anyone who triggers an error. It is the single most damaging misconfiguration.

Static and media files

  • Static files collected and served by the web server or a CDN, not by Django
  • Media uploads stored outside the code directory, ideally in object storage
  • Correct cache headers on static assets
  • Uploaded files never served from a path that could execute them

Migrations in the deployment

Migrations should run as a defined step in deployment, not manually afterwards. Manual migrations are forgotten, and a code version expecting a column that does not exist fails immediately.

Design them backwards-compatible where possible, so code can roll back without a database rollback.

The runtime stack

ComponentRole
Application serverRuns the Django code
Reverse proxyTLS, static files, buffering
Process supervisorRestarts anything that exits
Worker processesBackground tasks
SchedulerRecurring work

The development server should never run in production. It is single-threaded, unoptimised and explicitly not intended for it.

Health checks and logging

A health endpoint that checks the database and any critical dependency, so monitoring knows whether the application is actually working rather than merely running.

Logs to standard output, collected centrally. A log file on a server nobody reads is not logging.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

Containers or plain deployment?

Containers give consistency and add operational complexity. For a single application and a small team, plain deployment is frequently simpler.

How do we handle static files?

Collected at deploy time and served by the web server or a CDN. Never by Django in production.

What about zero-downtime deployment?

Achievable with an atomic switch and graceful shutdown. Backwards-compatible migrations make it practical.

Where should settings live?

Environment variables, with a settings module that reads them and fails fast if something required is missing.

Keep reading

More on Python & Django

Python & Django

An API Other Systems Can Depend On

Designing a Python API service others can depend on: validation at the boundary, consistent errors and status codes, early versioning and documentation.

Python & Django

Moving and Transforming Data Reliably

Building data pipelines in Python that cope with malformed input: restartable stages, quarantining failures, reconciling counts and alerting on absence.

Start here

Not sure your production settings are right?

Debug, allowed hosts and secret key are the three to check first. Quick to verify.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →