Contents

Chapter 1

Chapter 1: Getting Started & Project Setup

Multi-tenant Django foundation with Stripe billing, custom user model, and production-hardened settings — launch your SaaS in days.

What You Get

  • Custom User model — Email-based auth with roles, built from AbstractBaseUser
  • Multi-tenant architecture — Subdomain-based tenant resolution with shared database
  • Stripe billing — Plans, subscriptions, invoices, and webhook handling
  • Production settings — Whitenoise, S3 storage, Sentry, secure cookies, HSTS
  • REST API — Django REST Framework with JWT auth and OpenAPI docs
  • Docker-ready — Gunicorn, PostgreSQL, Redis, Celery worker
  • HTMX + Alpine.js — Modern server-rendered frontend without SPA complexity
  • Split settings — Base / development / production configuration pattern

File Tree

django-saas-boilerplate/
├── config/
│   ├── settings/
│   │   ├── base.py              # Shared Django settings
│   │   ├── development.py       # Dev overrides
│   │   └── production.py        # Production hardening
│   └── urls.py                  # Root URL configuration
├── apps/
│   ├── accounts/
│   │   ├── models.py            # Custom User model
│   │   ├── serializers.py       # DRF serializers
│   │   ├── views.py             # Auth & profile ViewSets
│   │   └── urls.py              # Account routes
│   ├── tenants/
│   │   ├── models.py            # Tenant & plan models
│   │   └── middleware.py        # Subdomain → tenant
│   └── billing/
│       ├── models.py            # Subscription & Invoice
│       └── webhooks.py          # Stripe webhook handler
├── templates/
│   └── base.html                # HTMX + Alpine.js base
├── docker/
│   ├── Dockerfile               # Multi-stage Django build
│   └── docker-compose.yml       # Full stack
├── manage.py
└── manifest.json

Requirements

  • Python 3.11+
  • PostgreSQL 15+
  • Redis 7+ (for Celery task queue)
  • Stripe account (for billing features)
Chapter 2

Chapter 2: Configuration & Running

Clone and configure

bash
cp .env.example .env
# Set DATABASE_URL, SECRET_KEY, STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET

Run with Docker

bash
docker compose -f docker/docker-compose.yml up -d
docker compose exec app python manage.py migrate
docker compose exec app python manage.py createsuperuser

Or run locally

bash
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver

Create a tenant

python
from apps.tenants.models import Tenant, Plan

plan = Plan.objects.create(
    name="Starter",
    stripe_price_id="price_xxx",
    max_users=5,
    monthly_price_cents=2900,
)

tenant = Tenant.objects.create(
    name="Acme Corp",
    subdomain="acme",
    plan=plan,
    owner=user,
)
# Access at: https://acme.yourdomain.com

Set up Stripe webhooks

bash
# Local development with Stripe CLI
stripe listen --forward-to localhost:8000/api/v1/billing/webhook/

# Production: configure webhook URL in Stripe dashboard
# https://yourdomain.com/api/v1/billing/webhook/
Chapter 3
🔒 Available in full product

Chapter 3: Architecture & Testing

You’ve reached the end of the free preview

Get the full Django SaaS Boilerplate and unlock everything.

All Chapters

Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.

Full Tool Suite

Access all interactive tools with complete data, all workload profiles, and the full scenario library.

Source Files

Downloadable source code, configuration files, and working examples from every chapter.

Lifetime Updates

Free updates for life. Every new chapter, tool, and improvement included.

Buy Now — $59 →
📦 Free sample included — download another copy for the full product.
Django SaaS Boilerplate v1.0.0 — Free Preview