A battle-ready Django template: generate a project and push it, and it deploys to your VPS over HTTPS with zero downtime and continuous database backups.
Docs • Quickstart • Features • Options • Architecture • Deploy • Contributing
Most Django templates get you as far as runserver. Then you still have to work out TLS certificates, reverse proxies, static files, image builds, deploy pipelines, rollbacks and backups yourself.
Django Combat ships those pieces already wired up. You generate a project, add a few GitHub secrets and push to master. CI runs your tests, builds the images, publishes them to GHCR and rolls them out to a single VPS with zero downtime. PostgreSQL archives every change, so you can restore the database to any minute.
The aim is a template you can take to production on day one, without needing Kubernetes.
🚀 Deployment
- Push to deploy. GitHub Actions builds images, pushes them to GHCR and deploys over SSH once CI passes.
- Zero-downtime rollouts.
docker rolloutbrings up the new backend before stopping the old one. - Release step. Migrations,
collectstaticand the first superuser run once per deploy, before traffic moves to the new version. - Automatic HTTPS. Traefik gets Let's Encrypt certificates, redirects
wwwto the apex domain and hides theServerheader. - Fast static files. A separate Nginx container serves
/static/and/media/, so Gunicorn only handles application requests.
🛡️ Database and reliability
- PostgreSQL 17 with WAL-G continuous archiving, nightly base backups and point-in-time restore.
- Optional S3-compatible backup storage (AWS, Cloudflare R2, MinIO and others) with libsodium encryption.
- Redis 8.4 cache and sessions through
django-redis. - Database connection pooling per Gunicorn worker, built into Django 5.2.
- Optional S3-compatible file storage for media and static files, with signed URLs for media.
- Health checks on every service, with separate liveness (
/api/health/) and readiness (/api/health/ready/) endpoints. - Ready for more servers. Containers keep no local state, so you can run several replicas behind a load balancer.
🔒 Security defaults
- HSTS (1 year, preload), secure cookies, SSL redirect and
X-Frame-Options: DENYin production. - Secure response headers through the
securemiddleware. - Containers run as a non-root user.
- Production refuses to start without
DJANGO_SECRET_KEYandDJANGO_ALLOWED_HOSTS.
🧰 Developer experience
- Python 3.14 and uv with a locked, reproducible dependency set.
- Split settings (
development/production/test), switched with oneDJANGO_ENVvariable. - Multi-stage Dockerfile with separate
development,testandproductiontargets and a BuildKit cache. - Hot reload in Docker with your source code mounted.
- Ruff, pre-commit, pytest and coverage set up from the start.
- Every option combination is tested. The template's own CI generates, lints, builds and tests all 8 variants on every push.
🧩 Optional integrations
- Django REST Framework with drf-spectacular OpenAPI docs.
- Wagtail 7 CMS.
- Vue 3 SPA with Vite 7, Tailwind CSS 4, Pinia, Vue Router and shadcn-vue-style components, built into the production image.
Prerequisites: uv, Docker with Compose v2, and git. You also need Node.js 22+ if you choose Vue.
# 1. Generate a project (answer the prompts)
uvx cookiecutter gh:h0pers/django-combat-template
# 2. Configure the environment
cd my-django-project
cp .env.example .env
# 3. Start the stack with hot reload
docker compose -f docker-compose.debug.yml up --buildOpen http://localhost. On first start the stack creates a superuser from the DJANGO_SUPERUSER_* values in .env (admin / admin by default). Log in at http://localhost/admin/.
| URL | What's there |
|---|---|
/admin/ |
Django admin |
/api/health/ |
Liveness check |
/api/health/ready/ |
Readiness check (PostgreSQL and Redis) |
/api/docs/ |
Swagger UI (with DRF, only when DEBUG is on) |
/cms/ |
Wagtail admin (with Wagtail) |
/app/ |
Vue SPA (with Vue) |
The generation step also runs uv lock, git init and an initial commit for you.
| Option | Default | Description |
|---|---|---|
project_name |
My Django Project |
Human-readable project name |
project_slug |
derived | Directory and package name, derived from project_name |
description |
A Django project |
Short project description |
author_name |
Your Name |
Author name |
use_drf |
y |
Django REST Framework, drf-spectacular and an example polls API |
use_wagtail |
n |
Wagtail CMS with a starter home page |
use_vue |
n |
Vue 3 + Vite + Tailwind SPA served by Django through django-vite |
To skip the prompts, pass the options on the command line:
uvx cookiecutter gh:h0pers/django-combat-template --no-input \
project_name="Acme Store" use_drf=y use_wagtail=n use_vue=yflowchart LR
user([Browser]) -->|HTTPS| traefik[Traefik<br/>TLS · Let's Encrypt]
traefik -->|/static, /media| nginx[Nginx]
traefik -->|everything else| backend[Django<br/>Gunicorn]
backend --> postgres[(PostgreSQL 17)]
backend --> redis[(Redis 8.4)]
postgres -->|WAL archiving| backup[WAL-G]
backup --> storage[(Volume or S3)]
What the generated project looks like
my-django-project/
├── .github/workflows/ # ci.yml · deploy.yml · pre-commit.yml
├── docker/
│ ├── nginx/ # static and media server image
│ └── postgres/ # PostgreSQL + WAL-G backup scripts
├── frontend/ # Vue 3 + Vite (only with use_vue)
├── website/
│ ├── apps/
│ │ ├── core/ # health check, security middleware
│ │ ├── polls/ # example API and SPA (DRF / Vue)
│ │ └── cms/ # Wagtail pages (only with use_wagtail)
│ └── website/settings/
│ ├── components/ # base, database, cache, security, ...
│ └── environments/ # development · production · test
├── Dockerfile # development / test / production targets
├── docker-compose.yml # production
├── docker-compose.debug.yml # local development
├── docker-compose.test.yml # test runner
└── pyproject.toml # uv-managed dependencies + Ruff config
Deployment targets a single Linux VPS that runs Docker and a shared Traefik instance.
Tip
Recommended: provision the server with vps-infra. It's a companion Ansible collection that turns a fresh Ubuntu 24.04 VPS into exactly the host Django Combat expects. It sets up Docker, docker rollout, a shared Traefik with Let's Encrypt, and one deploy user per app. It also hardens the server with iptables rate limits, fail2ban, unattended security upgrades and no root or password SSH. One server can host many Django Combat projects.
-
Prepare the server. With vps-infra, add your app as a deploy user in the inventory and run the playbook.
Setting up the server by hand instead
Install Docker and the
docker rolloutplugin. Run Traefik on an externaltraefik-publicnetwork with awebsecureentrypoint and alecertificate resolver. Create a non-root user in thedockergroup for deploys. -
Point your domain (and
www) at the server with an A record. -
Add GitHub secrets to the
productionenvironment:VPS_HOST,VPS_USER(the deploy user),SSH_PRIVATE_KEY,DJANGO_SECRET_KEY,POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DB,PACKAGES_TOKEN, plus theMY_DOMAINvariable. -
Push to
master. CI tests the project, and then the deploy workflow builds, publishes and rolls out the new version.
The generated project's README and the docs cover the full guide: the one-time systemd setup, Gunicorn tuning, files and backups in S3, running on more servers and the step-by-step restore procedure.
Contributions are welcome: bug reports, ideas and pull requests.
- Fork the repo and create a branch (
feat/...,fix/...). - Generate a project with your changes to check them:
uvx cookiecutter . --no-input. - Open a pull request. CI validates all 8 option combinations.
Commit messages follow Conventional Commits. See CONTRIBUTING.md for the full guide.
Please follow the Code of Conduct. Questions go through SUPPORT.md, and vulnerabilities through SECURITY.md.
Built on the shoulders of Django, Cookiecutter, uv, Traefik, WAL-G and docker-rollout, and inspired by cookiecutter-django.
If Django Combat saves you a weekend of DevOps, consider giving it a ⭐