← Django learning pathDjango · Module 10 of 10
Deploying Django
Prepare settings and run Django safely in production.
📖 Key ideas
- Set DEBUG = False and configure ALLOWED_HOSTS.
- Keep SECRET_KEY and DB passwords in environment variables.
- Run with gunicorn (WSGI) or uvicorn (ASGI) behind Nginx.
- collectstatic gathers static files; WhiteNoise or a CDN serves them.
- 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