Skip to content

Python

Deploy a Django app on Enzonic

Deploy recognises a Django project from manage.py and the project package's wsgi.py (application = get_wsgi_application()), installs your requirements and serves the WSGI application as a function on Python 3.12.

At a glance

What Enzonic Deploy does with a Django project when you connect it. You can override any of it in the project settings.

Language
Python
Detected from
django in requirements.txt, pyproject.toml or Pipfile; manage.py and <project>/wsgi.py containing get_wsgi_application
Build command
pip install -r requirements.txt
Output
Functions, plus public/ for collected static files
Runs as
Functions

How it runs

  • Functions

    Always.

Deploy Django step by step

  1. 1Read DATABASE_URL and SECRET_KEY from the environment in settings.py.
  2. 2Set ALLOWED_HOSTS to your Enzonic and custom domains.
  3. 3Collect static files into public/ (or serve them with WhiteNoise).
  4. 4Connect the repository and deploy.

Connect a database to Django

Create a database on Enzonic Databases (or from the project's settings) and its connection string is added to the project's environment variables. This example uses PostgreSQL.

settings.py
import os
import dj_database_url  # pip install dj-database-url

SECRET_KEY = os.environ['SECRET_KEY']
ALLOWED_HOSTS = ['.enzonic.dev', 'example.com']

DATABASES = {
    'default': dj_database_url.parse(os.environ['DATABASE_URL'], conn_max_age=60, ssl_require=True)
}

Postgres projects get two variables: DATABASE_URL through the connection pooler for the app, and DATABASE_URL_UNPOOLED for migrations.

PostgreSQL on Enzonic DatabasesEvery database engine

Things to know

  • Run migrations from your machine or CI against the database URL; functions do not run manage.py migrate on deploy.
  • DEBUG must be off in production; set it from an environment variable.

Plan limits that matter here

From the live plan data. Every plan includes previews for each branch, instant rollback, environment variables and logs.

Plan limits that matter for Django
LimitFreePro
Build minutes3,000/mo, 1 concurrent10,000/mo, 3 concurrent
Function memory / timeout1 GB / 300 s4 GB / 1800 s
Function invocations2 M/mo20 M/mo
Bandwidth150 GB/mo2 TB/mo

Compare every plan

Related guides

Ship your Django project tonight

Connect the repository and the build settings fill themselves in. Free plan, no card.

Start free