Skip to main content

⚙️ Configuration

A project is configured with environment variables in .env. Docker Compose passes them to the backend and the worker. The frontend receives only the variables it needs: never the full-access API key or the database password.

The backend reads them in config/settings.py through django_stack.settings.configure(), which sets Django's settings from the environment. Settings you define in config/settings.py before the call are kept, and dictionaries such as REST_FRAMEWORK are merged over the defaults.

Variables​

VariableDescription
SITE_URLThe public URL of the site.
BACKEND_URLThe public URL of the backend. In development the frontend's dev server serves /admin, /api and /media, so it is the same as SITE_URL.
DJANGO_SECRET_KEYDjango's secret key. Required.
DJANGO_DEBUG1 in development, 0 in production.
DATABASE_URLpostgres://user:password@host:5432/name, or sqlite:///path.
PRODUCTION_DATABASE_URLAn external Postgres for the server. dstack production makes it DATABASE_URL in .env.production and leaves out db; development keeps the bundled Postgres.
CACHE_URLdb:// for a table in the database, redis:// or valkey:// for Valkey, locmem:// for a cache per process.
TASKS_URLWhere the worker's task queue is: db:// (tables in the database), redis://cache:6379/1 (Valkey) or immediate:// (no worker: tasks run in the request, and there are no daily backups). Without it, the queue is in a Redis CACHE_URL, as in projects from before 0.7.
TASK_WORKERSThe number of worker containers: 1, or 0 with TASKS_URL=immediate://.
EMAIL_URLsmtp://user:password@host:25, smtp+tls:// for STARTTLS on port 587, smtps:// for TLS on port 465, or console:// to print mail.
DEFAULT_FROM_EMAILThe sender of the mail the site sends.
API_SECRET_KEYThe full-access API key, for scripts.
API_READ_KEYThe read-only API key, for the frontend. It must differ from API_SECRET_KEY.
PREVIEW_SECRETSigns preview links. Shared with the frontend.
REVALIDATE_SECRETSigns the requests that tell the frontend content changed. Shared with the frontend.
REVALIDATE_URLWhere the backend sends those requests.
ALLOWED_HOSTSExtra host names, separated by commas. The hosts of SITE_URL and BACKEND_URL are always allowed.
COMPOSE_PROFILESThe services Docker Compose starts: dev,db in development, prod,db on a server. Leave out db for an external Postgres (dstack production does with PRODUCTION_DATABASE_URL); add s3 in development for the local S3 service. analytics runs Umami, valkey the Valkey service.
NUM_PROXIESThe number of reverse proxies in front of the backend, so client IPs and HTTPS are detected. The prod profile sets 1, for Caddy.
S3_BUCKET and the other S3_*Store uploads in S3 instead of on disk. See Media and database.
UMAMI_URL and the other UMAMI_*Page analytics with Umami. See Page analytics.
BACKUP_TIME, BACKUP_KEEP, BACKUP_S3_BUCKETThe daily database backup. See Backups.
BACKUP_PING_URLRequested after each daily backup, for an alert when backups stop. See Health checks.
CADDY_ADDRESS, TRUSTED_PROXIES, HTTP_PORT, HTTPS_PORTCaddy behind a platform's proxy. See Coolify and Dokploy.
CAPTCHA, CAPTCHA_THROTTLE_RATEThe captcha of the contact form, on or off. See Captcha.
ERRORS, ERROR_EMAILError reports by email and in the admin, or to Sentry. See Error reports.
SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_RELEASE, SENTRY_TRACES_SAMPLE_RATEError reports to Sentry with ERRORS=sentry. See Sentry.
LOG_FORMAT, LOG_LEVEL, LOG_ACCESSThe format and level of the logs. See Logs and health checks.
SECURE_HSTS_INCLUDE_SUBDOMAINS, SECURE_HSTS_PRELOADExtend HSTS to subdomains and the preload list. Off by default.
ADMIN_USERNAME, ADMIN_EMAIL, ADMIN_PASSWORDThe admin user created on the first start.
SEED_DEMO_CONTENT1 adds the demo content to an empty site on the first start.

System checks​

python manage.py check reports configurations that are not safe:

CheckProblem
django_stack.E001The two API keys are the same.
django_stack.E002There is no read-only API key.
django_stack.E003Debug is on for an https site.
django_stack.E004An entry of DJANGO_STACK["PUBLIC_CREATE"] is not a model.
django_stack.W001A revalidation URL without a secret.
django_stack.W002No preview secret.
django_stack.W003The secret key is short (with --deploy).
django_stack.W004The cache is in local memory (with --deploy).
django_stack.W005An https site without NUM_PROXIES, so Django cannot tell requests came over HTTPS (with --deploy).
django_stack.W006UMAMI_URL without UMAMI_ADMIN_PASSWORD or UMAMI_WEBSITE_ID.