Operations manual

Set up · 02

Configuration and secrets

Configuration is split between environment variables for infrastructure and database-backed settings for storefront behaviour. This page explains which value belongs where and which ones production refuses to start without.

ConfigurationSecretsEnvironmentReviewed November 2026
The Perfumz settings workbench
Settings workbenchConfiguration

Settings modules

ModuleUsed byBehaviour
config.settingsDevelopment, tests, management commandsLoads .env, defaults to SQLite unless POSTGRES_DB is set, and enables local static serving.
config.settings_productionGunicorn on the VPSForces DEBUG=False, requires PostgreSQL and a strong secret, enables HTTPS/HSTS/secure cookies, file logging and production host validation.

Both modules import the same application settings. Production overrides the unsafe development defaults instead of maintaining a second application configuration.

Environment precedence

The base settings read .env from the application root, but only through os.environ.setdefault. A real environment variable always wins. systemd loads .env through EnvironmentFile=, so the running service sees the same values without the shell having to source the file.

# Inspect the effective production values without printing secrets
.venv/bin/python - <<'PY'
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings_production')
import django
django.setup()
from django.conf import settings
print(settings.DEBUG, settings.DATABASES['default']['ENGINE'])
print(settings.SITE_URL, settings.SHORTLINK_DOMAIN)
PY

Do not commit .env. The production template is deploy/env.production.example; the local template is .env.example.

Core values

VariableProduction requirementWhy it matters
DJANGO_SECRET_KEYRequired, 50+ characters, 5+ unique, no django-insecure- prefixSigns sessions, password reset tokens and security primitives.
DJANGO_ALLOWED_HOSTSCanonical domain, www and optional short hostRejects unknown Host headers.
DJANGO_CSRF_TRUSTED_ORIGINSFull https:// originsAllows authenticated form posts behind TLS.
SITE_URLMust start with https://Canonical links in email, affiliate and share surfaces.
SHORTLINK_DOMAINOptional subdomain of SITE_URLEnables go.example.com/<code>; otherwise use /i/<code>/.
DB_ENGINEpostgresql on the VPSsqlite is reserved for local production-equivalence checks.

Database

Development uses SQLite when no POSTGRES_DB is present. To use PostgreSQL locally, set the POSTGRES_* values. Production uses the DB_* names and defaults to PostgreSQL with connection reuse and health checks.

DB_ENGINE=postgresql
DB_NAME=perfumz
DB_USER=perfumz
DB_PASSWORD=change-me
DB_HOST=127.0.0.1
DB_PORT=5432
DB_CONN_MAX_AGE=600

The production settings raise ImproperlyConfigured when DB_NAME is missing or the engine is unsupported. The readiness endpoint runs SELECT 1 and reports the database check in JSON.

Email and providers

AreaPrimary variablesNotes
EmailDJANGO_EMAIL_*, DEFAULT_FROM_EMAIL, TRANSACTIONAL_EMAIL_PROVIDERSMTP is the default. Optional Resend, SendGrid, Postmark and Mailgun keys are read by the mailer.
PaymentsSTRIPE_*, FLW_*, PAYPAL_*, PAYMENT_PROVIDERConfigure only the provider you intend to offer. Webhook secrets are required for signed callbacks.
NewsletterNEWSLETTER_ESP, MAILCHIMP_*Local capture is the default; Mailchimp adds list sync and webhook processing.
PushVAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY, VAPID_SUBJECTGenerate a pair with python manage.py generate_vapid_keys.
AIAI_PROVIDER, OPENAI_API_KEY, OPENAI_MODELlocal keeps the assistant deterministic; openai enables hosted generation.

Database-backed settings

Storefront copy, logo URLs, currency, tax, free-shipping threshold, low-stock threshold, order prefix, payment provider, cookie consent, SEO defaults, social links and feature flags live in SiteSettings. Edit them at /dashboard/settings/. Theme colours, logos and typography live in the Content Studio theme panel and ThemeSettings.

Changing a database-backed setting does not require a deploy. Changing an environment variable does require a service restart because systemd reads .env at start and Gunicorn loads settings once per worker.

The settings workbench can send a test email and shows integration health. It never displays or stores provider secrets in the browser.

Production guardrails

.venv/bin/python manage.py check --deploy --settings config.settings_production
bash deploy/verify.sh

check --deploy must report no warnings. deploy/verify.sh runs the production settings against a temporary database and Gunicorn, including the HTTPS redirect, HSTS, frame headers and readiness probes.

Perfumz Operations Manual · English reference · Reviewed November 2026