← Django learning path
Django · Module 10 of 10

Deploying Django

Prepare settings and run Django safely in production.

📖 Key ideas

  1. Set DEBUG = False and configure ALLOWED_HOSTS.
  2. Keep SECRET_KEY and DB passwords in environment variables.
  3. Run with gunicorn (WSGI) or uvicorn (ASGI) behind Nginx.
  4. collectstatic gathers static files; WhiteNoise or a CDN serves them.
  5. Use PostgreSQL in production and run check --deploy.
💡 Real-life example: Going live is opening a shop: lock the back office (DEBUG off), hire a doorman (Nginx) and keep the keys safe (env vars).
DEBUGShows detailed errors; must be False in production
ALLOWED_HOSTSDomains the site serves
gunicornProduction WSGI server
collectstaticGathers static files