Django Deployment Checklist
In this page:
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.
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.
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.
# 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.
- Running the development server (runserver) in production instead of a real WSGI server.
- Skipping migrations on the production database after deploying new model changes.
- Storing the production SECRET_KEY in version control instead of an environment variable.
- 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.
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: