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
- 1Read DATABASE_URL and SECRET_KEY from the environment in settings.py.
- 2Set ALLOWED_HOSTS to your Enzonic and custom domains.
- 3Collect static files into public/ (or serve them with WhiteNoise).
- 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.
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 engineThings 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.
| Limit | Free | Pro |
|---|---|---|
| Build minutes | 3,000/mo, 1 concurrent | 10,000/mo, 3 concurrent |
| Function memory / timeout | 1 GB / 300 s | 4 GB / 1800 s |
| Function invocations | 2 M/mo | 20 M/mo |
| Bandwidth | 150 GB/mo | 2 TB/mo |
Related guides
- Deploy a Flask appFlask (and Quart) apps served as WSGI/ASGI functions.
- Deploy a FastAPI appFastAPI (and Starlette) apps as ASGI functions on Python 3.12.
- Deploy a Python functions appPlain Python handlers in api/*.py, no framework needed.
Ship your Django project tonight
Connect the repository and the build settings fill themselves in. Free plan, no card.