eriktaveras/django-saas-boilerplate
Acerca de
A modern, production-ready Django boilerplate for building SaaS applications with HTMX, Tailwind CSS, and Alpine.js. This template provides everything you need to kickstart your next SaaS project with best practices and modern tooling.
Desarrollo web y de aplicacionesCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
OriginalDjango SaaS Boilerplate
The open-source Django starter kit for building SaaS applications. Auth, payments, dashboard, and deployment — all wired up.
What this is
A small, finished SaaS starter. Sign up, log in, land on a dashboard, pay with a card, and there is a public site in front of it. That is the whole scope, and it is deliberate: it is what you need on a Saturday morning to stop configuring and start building the thing you actually wanted to build.
Everything below works out of the box.
- Custom user model — email-only login, no username
- Authentication — signup, login, email verification, password reset (django-allauth), 21 styled templates
- Stripe subscriptions — Payment Methods API, pinned API version, signed webhook, subscription status on the user
- User dashboard — sidebar nav, profile, notification settings, API key generation (hashed, shown once)
- Subscription plans — admin-managed plans with trial support
- Landing pages — home, features, pricing,
robots.txt - Tasks — Django 6.0 native
@task(), executed immediately with the configured backend - Content Security Policy — Django 6.0 CSP middleware with nonces
- Security headers — HSTS, SSL redirect, secure cookies (auto-enabled in production)
- PostgreSQL support —
DATABASE_URLwith SQLite fallback - Static files — WhiteNoise, no nginx needed
- Deployment — Gunicorn + Procfile, ready for Railway/Heroku/VPS
- Linting — Ruff with Django-specific rules
- Tests — landing pages, auth, dashboard, models, Stripe checkout and webhook
- Seed data — one command to populate demo data
What it does not do
Worth knowing before you build on it, so you can decide what to add yourself:
- No teams or multi-tenancy. One user, one account. There is no concept of an organisation, a member, or a role.
- No plan gating.
SubscriptionPlan.featuresis a JSON list for the pricing page — marketing copy, not entitlements. Nothing in the code stops a free user from using a paid feature, and there are no usage counters or quotas. - Two places still track a subscription.
StripeCustomermirrors Stripe;UserSettingsholds what the dashboard gates on. Paying now grants access and cancelling cancels at Stripe, so the money and the access agree — but they are still two records kept in step by one function, not one model. Anything past that (per-plan entitlements, seats, usage counters) starts from scratch. - Minimal billing lifecycle. The webhook handles subscription created/updated/deleted. No failed-payment recovery, no customer portal, no invoice history.
- No REST API. The dashboard mints and hashes an API key, but nothing authenticates with it yet — it is a starting point, not an API.
- Tailwind and Alpine come from a CDN. No build step, which is why setup is one command. Before production you will want a real Tailwind build.
- No Docker, no CI.
make runand a Procfile.
MIT licensed. Fork it, rename it, ship it, sell it — no attribution required.
Tech stack
| Layer | Technology |
|---|---|
| Backend | Django >=6.0,<6.2, Python 3.12+ |
| Auth | django-allauth (email-only) |
| Payments | Stripe SDK 15.x (Payment Methods API) |
| Frontend | Tailwind CSS (CDN), Alpine.js, HTMX |
| Database | SQLite (dev) / PostgreSQL (prod) |
| Static files | WhiteNoise |
| Server | Gunicorn |
| Tasks | Django 6.0 native @task(), ImmediateBackend |
| Linting | Ruff |
Quick start
Requires Python 3.12+. On Debian or Ubuntu you also need the venv package,
or make install fails with ensurepip is not available:
sudo apt install python3.12-venv
git clone https://github.com/eriktaveras/django-saas-boilerplate.git
cd django-saas-boilerplate
make install
cp .env.example .env
make migrate
make seed
make run
Every make target runs through the virtualenv that make install creates, so
there is nothing to activate.
Visit http://localhost:8000. seed_data prints the generated admin password once — copy it from the terminal. Set SEED_ADMIN_EMAIL / SEED_ADMIN_PASSWORD to choose your own.
Commands
| Command | Description |
|---|---|
make install |
Create virtualenv and install dependencies |
make run |
Start development server |
make migrate |
Run makemigrations + migrate |
make test |
Run the test suite |
make seed |
Populate demo data (admin + plans) |
make lint |
Lint with ruff |
make format |
Format with ruff |
make superuser |
Create admin user |
make clean |
Remove pycache files |
Local validation
Install dependencies into venv using make install, or with uv:
uv venv venv --python 3.12
uv pip install --python venv/bin/python -r requirements.txt
Run the project checks locally (there is no CI):
DEBUG=True venv/bin/python manage.py test
DEBUG=True venv/bin/python manage.py check
DEBUG=True venv/bin/python manage.py makemigrations --check --dry-run
venv/bin/ruff check .
The suite defines 67 tests: accounts 6, dashboard 21, landing 4, and
subscriptions 36. Stripe calls are mocked; tests need no live Stripe credentials.
DEBUG=True permits the development secret key; with debug off, SECRET_KEY
is required. Copying .env.example to .env also sets up development defaults.
PostgreSQL deployments additionally need a compatible PostgreSQL driver
(e.g. psycopg), which is not included in requirements.txt.
See subscription behavior and webhook setup.
Project structure
django-saas-boilerplate/
├── core/
│ ├── settings.py # All config via env vars
│ ├── urls.py # Root URL routing
│ ├── wsgi.py
│ └── asgi.py
├── apps/
│ ├── accounts/ # CustomUser (email-only), admin
│ │ ├── models.py # CustomUser + CustomUserManager
│ │ ├── admin.py
│ │ └── tests.py # App tests
│ ├── dashboard/ # Dashboard, profile, settings
│ │ ├── models.py # SubscriptionPlan, UserSettings
│ │ ├── views.py # dashboard, profile, settings, plans
│ │ ├── tasks.py # Email tasks (immediate execution)
│ │ ├── tests.py # App tests
│ │ └── management/commands/seed_data.py
│ ├── subscriptions/ # Stripe integration
│ │ ├── models.py # StripeCustomer
│ │ ├── views.py # checkout, webhooks
│ │ └── tests.py # App tests
│ └── landing/ # Public pages
│ ├── views.py # home, features, pricing, robots.txt
│ └── tests.py # App tests
├── templates/
│ ├── base.html # Public layout (nav + footer)
│ ├── account/ # 21 allauth templates (styled)
│ ├── dashboard/ # Dashboard layout + pages
│ ├── landing/ # Home, features, pricing
│ └── subscriptions/ # Stripe checkout
├── static/css/ # Design system CSS
├── CLAUDE.md # AI editor context
├── Makefile # Dev commands
├── Procfile # Deployment
├── pyproject.toml # Ruff config
├── requirements.txt
└── .env.example
Environment variables
Copy .env.example to .env and configure:
# Required
DEBUG=True
SECRET_KEY=your-secret-key
# Database (default: SQLite)
# DATABASE_URL=postgres://user:password@localhost:5432/dbname
# Stripe (required for payments)
STRIPE_PUBLIC_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PRICE_ID=price_...
# Email (console in DEBUG; SMTP otherwise)
# EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
# EMAIL_HOST=smtp.gmail.com
# EMAIL_PORT=587
# [email protected]
# EMAIL_HOST_PASSWORD=your-app-password
Django 6.0+ features used
This boilerplate uses two features introduced in Django 6.0:
Tasks — Email tasks use Django’s native task API. The configured
django.tasks.backends.immediate.ImmediateBackend executes .enqueue()
synchronously in the calling process, including during requests. There is no
worker or durable queue; asynchronous execution requires another backend and
its worker infrastructure. The email tasks live in apps/dashboard/tasks.py;
the following is a simplified example:
from django.tasks import task
@task
def send_subscription_confirmation_email(user_email, plan_name):
send_mail("Subscription Confirmed", plan_name, None, [user_email])
# In your view:
send_subscription_confirmation_email.enqueue(user_email=user.email, plan_name=plan.name)
Content Security Policy — Built-in CSP middleware with nonce support:
SECURE_CSP = {
"script-src": [CSP.SELF, CSP.NONCE],
"style-src": [CSP.SELF, CSP.UNSAFE_INLINE],
}
<script nonce="{{ csp_nonce }}" src="..."></script>
Deployment
Railway
Push to GitHub and connect to Railway. The Procfile and DATABASE_URL handling are already configured.
Heroku
heroku create your-app-name
heroku config:set SECRET_KEY=your-secret-key
heroku config:set DEBUG=False
git push heroku main
heroku run python manage.py migrate
VPS
pip install -r requirements.txt
python manage.py migrate
python manage.py collectstatic --noinput
gunicorn core.wsgi --bind 127.0.0.1:8000
Bind to localhost and put nginx or Caddy in front, terminating TLS. The app
trusts the X-Forwarded-Proto header to decide whether a request arrived over
HTTPS, which is what platforms like Railway and Heroku set. Exposing gunicorn
directly on 0.0.0.0 lets a client send that header itself and walk straight
past SECURE_SSL_REDIRECT.
If you need the other half
Some of what is missing above is a weekend of work. Some of it is not — plan gating, dunning and GDPR flows are the parts that quietly eat a month.
DjangoBlaze is the paid version of this boilerplate, and it is where that work already lives:
- Teams and multi-tenancy
- Per-plan feature gating with usage limits
- REST API with hashed keys
- AI chat
- Blog with SEO
- Two-factor authentication
- Dunning (failed-payment recovery)
- GDPR account deletion and data export
- Docker, CI
- 24 AI skills for working on the codebase
8 apps, 203 tests. $99 one time, unlimited projects, one year of updates.
No pressure either way — this repo is MIT and stays that way.
Contributing
See CONTRIBUTING.md for guidelines.
License
MIT License. See LICENSE for details.
Author
Erik Taveras — Full Stack Developer
Star History
Explorar proyectos relacionados
Cargando…