Skip to content

Deploy a Django app

Push your code to GitHub, start a new app, pick the repository and click Deploy with Drone. Or run hivepod deploy in the project folder.

Pick Django. DockHive installs requirements.txt and serves your project’s WSGI app with gunicorn. Include gunicorn in requirements.txt.

ALLOWED_HOSTS must include your app’s address and any custom domains, or Django refuses requests:

settings.py
import os
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",")
CSRF_TRUSTED_ORIGINS = [f"https://{h}" for h in ALLOWED_HOSTS if h]
DEBUG = os.environ.get("DEBUG") == "1"
SECRET_KEY = os.environ["SECRET_KEY"]

Then set these environment variables:

ALLOWED_HOSTS=wonder-web-8ml2.dockhive.app,www.example.com
SECRET_KEY=a-long-random-string
DATABASE_URL=postgresql://...

Static files: serve them with WhiteNoise and run collectstatic in your build command.

Migrations: run python manage.py migrate as part of your start command, for example:

Terminal window
python manage.py migrate && gunicorn myproject.wsgi --bind 0.0.0.0:$PORT

If the build says it can’t find wsgi.py, set the Start Command yourself as above.