Skip to main content
This guide walks a Django 4+ app from local code to a production URL with a database and per-user auth. Every step has runnable Python code. By the end you have a working app at https://<app>.on.getfloo.com with a Postgres sibling service, signed-in users, and (optionally) your own domain. If you’ve never deployed to floo before, read Golden Path first for the minimal three-command flow.

Before you start

You need:
  • A Django 4+ project (or a fresh django-admin startproject mysite).
  • The project pushed to a GitHub repository.
  • The floo CLI installed and authenticated (curl -fsSL https://getfloo.com/install.sh | bash then floo auth login).

1. Add a Dockerfile

Dockerfile
Add gunicorn and dj-database-url to your requirements.txt:
Bind to 0.0.0.0, not 127.0.0.1. Cloud Run only routes traffic to processes bound to all interfaces.

2. Configure Django for production

Update mysite/settings.py to read floo’s runtime env vars:
mysite/settings.py
Generate a real DJANGO_SECRET_KEY and set it once the app exists (step 4).

3. Initialize the floo config

floo.app.toml
migrate_command runs after every deploy and promote.

4. Connect the repo and deploy

Set the secret key once the app exists, then redeploy:
Your Django app is live at https://my-django-app-dev.on.getfloo.com.

5. Add a Postgres database

floo.app.toml
DATABASE_URL is injected. dj-database-url parses it automatically — no settings change needed. The next deploy runs your migrate_command against the new database before traffic shifts.

6. Add per-user auth

floo manages user authentication for you. Set access_mode = "accounts" in floo.app.toml:
floo.app.toml
Push and deploy. From the next deploy onward, floo’s gateway sits in front of your app and:
  • Redirects unauthenticated requests to a hosted login page.
  • Validates the session cookie on every request.
  • Injects identity headers into every request that reaches your Django app.
Add a tiny middleware that hangs the floo user on request.floo_user:
mysite/middleware.py
Wire it up:
mysite/settings.py
Use it in views:
mysite/views.py
For local development, send the headers yourself or extend the middleware to inject a fixture user when they’re missing. For the full reference on access modes and identity headers, see Add User Auth to Your App.

7. Add a custom domain

Add the traffic and _floo-verify TXT records shown by floo domains add, then run floo domains verify app.example.com --app my-django-app. USE_X_FORWARDED_HOST = True and SECURE_PROXY_SSL_HEADER mean Django builds correct absolute URLs (for redirects, mailers, request.build_absolute_uri) without extra config.

8. Local development with prod data

Runs dev_command locally with DATABASE_URL and other env vars sourced from your dev floo app — real Cloud SQL connection, no credentials in your shell history. To also test signed-in flows for this accounts-mode app, add --fixture-user:
floo dev then starts a small proxy in front of each service that injects the same X-Floo-User-* headers floo’s gateway adds in production. The output table shows both the raw service URL and the auth-proxied URL — hit the auth-proxied one for any path that reads identity headers.

Common gotchas

  • /healthz is reserved. Cloud Run’s edge intercepts that exact path. Use /health or /livez.
  • Bind to 0.0.0.0. 127.0.0.1 won’t accept Cloud Run traffic.
  • DEBUG = True in prod is a security hole. Set DJANGO_DEBUG=false (or just don’t set it — the default in the example above).
  • DJANGO_SECRET_KEY must be set. Without it, Django’s session cookies can be forged. Generate with get_random_secret_key() and set via floo env set.
  • collectstatic runs in the Dockerfile. WhiteNoise’s CompressedManifestStaticFilesStorage requires it.
  • SECURE_PROXY_SSL_HEADER is required behind a proxy. Without it, request.is_secure() returns False and Django redirect loops can form when SECURE_SSL_REDIRECT=True.

What’s next

Add User Auth — full reference

Identity headers, access policies, and access modes in detail.

Managed Services

Postgres, Redis, Storage — what they cost and how isolation works.

Custom Domains

DNS, verification, multi-service routing.

Cron Jobs

Schedule recurring Django management commands inside your container.