← Back to Django Course | Chapter 15: Security, Caching & Deployment | Lesson 7 of 9

Django Deployment Checklist

A deployment checklist is like a pilot's pre-flight checklist -- a short list you run through every time so a small mistake doesn't turn into a big problem once you're in the air.

Installing a Production Server

manage.py runserver is a lightweight development server not built to handle real traffic safely or efficiently. Gunicorn is a WSGI server that runs the same Django application in a production-appropriate way.

Example: Installing a Production Server

manage.py runserver is a lightweight development server not built to handle real traffic safely or efficiently. Gunicorn is a WSGI server that runs the same Django application in a production-appropriate way.

bash
pip install gunicorn
gunicorn myproject.wsgi:application

⚠️ Run this command in your terminal.

Applying Migrations on Deploy

Every deploy that includes new model changes needs its migrations applied to the production database, exactly like during development, just pointed at the live database instead of the local one.

Note: Run migrate as part of every deploy, even ones that feel like they only changed templates.

Example: Applying Migrations on Deploy

Every deploy that includes new model changes needs its migrations applied to the production database, exactly like during development, just pointed at the live database instead of the local one.

bash
python manage.py migrate

⚠️ Run this command in your terminal.

A Minimal Deployment Checklist

Before each deploy, a short list of checks catches the most common mistakes: DEBUG is off, ALLOWED_HOSTS is correct, static files are collected, and migrations are applied.

Example: A Minimal Deployment Checklist

Before each deploy, a short list of checks catches the most common mistakes: DEBUG is off, ALLOWED_HOSTS is correct, static files are collected, and migrations are applied.

bash
# Deployment checklist (run in order)
# 1. python manage.py check --deploy
# 2. python manage.py collectstatic --noinput
# 3. python manage.py migrate
# 4. gunicorn myproject.wsgi:application

⚠️ Run this command in your terminal.

Common Mistakes
  1. Running the development server (runserver) in production instead of a real WSGI server.
  2. Skipping migrations on the production database after deploying new model changes.
  3. Storing the production SECRET_KEY in version control instead of an environment variable.
Chapter Summary
  • Production Django needs a real WSGI application server like Gunicorn, not manage.py runserver.
  • Migrations must be applied on the production database, not just the local one.
  • Environment-specific settings (secret key, debug flag, allowed hosts) should come from the environment, not the codebase.
  • A short, repeatable checklist prevents the same mistakes from happening on every release.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.