w wokku
Get Started
~/docs
/
frameworks

# Deploy Django

Updated · Edit on GitHub ↗

Deploy a Django app to Wokku with Postgres, automatic migrations, and static
files served via WhiteNoise.

Prerequisites

1. Create the app

Apps → New App → server, name my-django-app, box size, Create.

2. Prepare your Django app

The Python buildpack detects requirements.txt. Make sure these are present:

text
# requirements.txt
django
gunicorn
psycopg[binary]
whitenoise
dj-database-url

Add a Procfile:

procfile
web: gunicorn myproject.wsgi --log-file -
release: python manage.py migrate --noinput

In settings.py, read the database + host from the environment and let
WhiteNoise serve static files:

python
import dj_database_url, os
DATABASES = {"default": dj_database_url.config(conn_max_age=600)}
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",")
MIDDLEWARE = ["whitenoise.middleware.WhiteNoiseMiddleware", *MIDDLEWARE]
STATIC_ROOT = BASE_DIR / "staticfiles"
// note

3. Set environment variables

App → Config:

Key Value
SECRET_KEY a long random string
DJANGO_SETTINGS_MODULE myproject.settings
ALLOWED_HOSTS my-django-app.wokku.app
DEBUG False

4. Add a database

bash
wokku addons:create postgres my-django-app

Wokku injects DATABASE_URL; dj-database-url reads it automatically. See
Create & Link a Database.

5. Deploy

bash
git remote add wokku git@git.wokku.cloud:my-django-app
git push wokku main

Live at https://my-django-app.wokku.app.

6. Custom domain

Custom Domains — remember to add the new
hostname to ALLOWED_HOSTS and redeploy.

Troubleshooting

  • DisallowedHost — add your domain to ALLOWED_HOSTS and redeploy.
  • CSS/JS 404 in production — confirm WhiteNoise middleware + STATIC_ROOT; collectstatic must succeed in the build log.
  • Migrations didn’t run — check the release: line and the deploy logs.

Next steps

Was this page helpful?