How to Deploy a Django App: A Beginner's Checklist
Everything a Django app needs before it goes live: secret settings, DEBUG, PostgreSQL, static files, Gunicorn, HTTPS, check --deploy, hosting choices and what to do after launch.

Your Django site works perfectly with python manage.py runserver. Now you want the world to see it. Going live is where many beginners get stuck, because a few settings that are fine on your laptop are dangerous on the internet.
This checklist walks through everything a Django app needs before and after it goes live, in the order you'll meet it. Work through it once and every deploy after that becomes routine.
1. Keep secrets out of your code
Your SECRET_KEY, database password and API keys must never be committed to Git. Read them from environment variables instead, and set those on your server or hosting platform:
import os
SECRET_KEY = os.environ["SECRET_KEY"]
DEBUG = os.environ.get("DEBUG") == "1"
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",")
Generate a fresh secret key for production rather than reusing the one from your laptop. Keep a .env.example file in your repository that lists the variable names, with no real values, so the next developer knows what to set.
2. Turn DEBUG off
With DEBUG = True, an error page shows visitors your settings, your code and your file paths. In production, DEBUG must be False. With it off, Django also needs to know which domain names it serves:
ALLOWED_HOSTS = ["example.com", "www.example.com"]
CSRF_TRUSTED_ORIGINS = ["https://example.com", "https://www.example.com"]
3. Use a real database
SQLite is great for learning, but most live sites use PostgreSQL: it handles many visitors at once and most hosts offer it ready-made. Hosts usually give you a single DATABASE_URL; the dj-database-url package turns it into Django's settings:
import dj_database_url
DATABASES = {"default": dj_database_url.config(conn_max_age=600)}
Run python manage.py migrate on every deploy, so the live database always matches your models.
4. Serve your static files
runserver serves your CSS, JavaScript and images for you; production does not. The simplest fix is WhiteNoise. Add its middleware right after Django's security middleware, tell Django where to collect the files, and run collectstatic on each deploy:
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
# ... the rest of your middleware
]
STATIC_ROOT = BASE_DIR / "staticfiles"
STORAGES = {
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
"staticfiles": {"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage"},
}
5. Run a real application server
runserver is for development only. In production a WSGI server such as Gunicorn runs your app:
gunicorn mysite.wsgi --bind 0.0.0.0:8000 --workers 3
Replace mysite with the folder that holds your settings.py. Many platforms start this command for you from a start command or a Procfile.
6. Switch on HTTPS settings
Every live site should use HTTPS, and Django can insist on it:
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_HSTS_SECONDS = 3600 # raise this once everything works
If your host sits behind a proxy that handles HTTPS for you, follow its docs for SECURE_PROXY_SSL_HEADER, or the redirect can loop forever.
7. Let Django check your settings
Django has a built-in checklist. Run it with your production settings and fix every warning it prints:
python manage.py check --deploy
8. Pin your packages
Your server must install exactly the versions you tested with. Save them to requirements.txt and commit it:
python -m pip freeze > requirements.txt
9. Choose where to host it
- PythonAnywhere: the gentlest start. Upload your code, point it at your virtual environment and WSGI file, and you're live.
- Container platforms such as Railway, Render or Fly.io: connect your GitHub repository and they build and run your app, often from a Dockerfile, with a managed PostgreSQL database alongside. JeliScript itself runs on Railway.
- Your own Linux server (a VPS): the most control and the most to learn, with Nginx in front of Gunicorn, systemd keeping it running, and certificates from Let's Encrypt.
10. After you go live
- Logs and error alerts: make sure errors are logged somewhere you'll see them, and consider an error tracking service that emails you when something breaks.
- Backups: back up your database on a schedule, and practise restoring one before you need it.
- Automatic deploys: run your tests on every push with GitHub Actions and deploy only when they pass.
- Updates: security fixes arrive all the time. Update Django and your packages regularly, and use a tool like
pip-auditto spot known problems.
Learn it step by step
- The Ultimate Django Course builds a complete blog and puts it live on PythonAnywhere.
- Deploying Your Web App goes further: production settings, PostgreSQL and backups, Docker, container platforms, your own Linux server, background tasks, logs and automatic deploys.
- Web Security and Logins covers the security side: passwords, sessions and tokens, security headers and keeping packages updated.
The Backend Developer roadmap shows where deployment fits among everything else.
Comments
Log in to join the conversation.
Loading comments...


