Quite the opionionated Django starter template
This template assumes you want:
- β‘ Speed over flexibility (UV instead of Poetry/pip)
- π§Ή Fewer tools that do more (Ruff instead of Black + Flake8 + isort)
- π Type safety (because
Any
is not a type) - π€ Automation (Dependabot keeping you current)
- π¨ Consistency (standardized everything)
If you disagree with these choices, this template will make you very unhappy. Consider yourself warned! π
Category | Choice | Why This & Not That |
---|---|---|
Dependency Manager | UV | 10x faster than Poetry. Life's too short for slow installs. |
Code Formatter | Ruff | Replaces Black + Flake8 + isort + 12 other tools. One tool to rule them all. |
Type Checker | MyPy | Because def process_data(data): tells us nothing about what happens when you pass it a sandwich. |
Database | PostgreSQL | SQLite is for prototypes. This is for production. |
Task Queue | Celery + Redis | Send emails without blocking the UI. Revolutionary! |
Testing | PyTest + Hypothesis | Property-based testing finds bugs you didn't know you had. |
Security Scanner | Bandit | Catches security issues before your CISO does. |
Dependency Updates | Dependabot | Auto-updates dependencies so you don't have to remember. |
Web Server | Caddy | Automatic HTTPS. It's 2025, people! |
Containerization | Docker | "Works on my machine" β "Works on every machine" |
Static Assets | Webpack | Because <script src="jquery-1.4.2-final-FINAL-v2.js"> is not a build system. |
Required (or your project will explode):
- Python 3.12+ (3.11 if you enjoy living dangerously)
- PostgreSQL 12+ (because you're not a savage)
- Redis 6+ (for caching and background tasks)
- UV package manager (the future is here)
Optional (for the full experience):
- Node.js 18+ (for asset compilation)
- Docker (for "works on everyone's machine")
Click "Use this template"
Instead of running django-admin startproject
to start your new project, clone this repo in a directory of your choosing
git clone https://github.com/CynthiaWahome/django-starter-project.git django-starter
cd django-starter
python scripts/setup_project.py
This magical script will:
- Install UV (if you forgot)
- Install all dependencies
- Setup pre-commit hooks (no more "oops" commits)
- Create and migrate database
- Collect static files
- Make you coffee β (just kidding, but everything else is real)
At this point you may start a clean git repo by removing the .git
directory and then running git init
.
cp .env.example .env
You have two choices, either you turn every service on your own or you use docker-compose
docker-compose up --build
Visit http://127.0.0.1:8000 and you'll see your site up and running π§ββοΈ
Make sure you have redis-server
running and finally on 3 separate consoles run:
server
uv run python manage.py runserver
worker
uv run celery -A conf worker --loglevel=info
webpack
cd assets
npm install
npm run dev
Visit http://127.0.0.1:8000 and you'll see your site up and running π§ββοΈ
django-starter-project/
βββ π apps/ # Your Django applications
β βββ π common/ # Shared utilities
β βββ π misc/ # Miscellaneous utilities
β βββ π users/ # User management
βββ π assets/ # Frontend assets (SCSS, JS, images)
βββ π conf/ # Django project configuration
β βββ settings.py # The main settings file
β βββ urls.py # Root URL configuration
β βββ wsgi.py # WSGI entrypoint
β βββ celery.py # Celery configuration
βββ π scripts/ # Utility and setup scripts
β βββ π entrypoint-django.sh # Docker entrypoint script for Django
β βββ π entrypoint-celery.sh # Docker entrypoint script for Celery
β βββ setup_db.sh # Database setup script
β βββ setup_project.py # Project setup automation
βββ π templates/ # Django templates
βββ π tests/ # Test suite
β βββ conftest.py # Pytest configuration
β βββ test_int.py # Integration tests
β βββ test_responses.py # Response tests
βββ π .env.example # Environment variable template
βββ π .gitignore # Git ignore rules
βββ π .pre-commit-config.yaml # Pre-commit hook definitions
βββ π Caddyfile # Caddy web server configuration
βββ π docker-compose.yml # Docker Compose orchestration
βββ π Dockerfile # Main container definition
βββ π manage.py # Django's command-line utility
βββ π pyproject.toml # Project metadata and dependencies (PEP 621)
βββ π README.md # This file
All API endpoints follow a standardized response format:
{
"success": true,
"message": "Data retrieved successfully",
"data": {
"user": {
"id": 1,
"email": "[email protected]",
"created_at": "2025-01-01T00:00:00Z"
}
},
"error": null,
"metadata": {}
}
{
"success": false,
"message": "Validation failed",
"data": null,
"error": {
"code": "VALIDATION_ERROR",
"details": {
"email": ["This field is required."],
"password": ["Password must be at least 8 characters."]
}
},
"metadata": {}
}
{
"success": true,
"message": "Users retrieved successfully",
"data": [
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
],
"error": null,
"metadata": {
"pagination": {
"total_items": 42,
"total_pages": 5,
"current_page": 1,
"per_page": 10,
"has_next": true,
"has_previous": false
}
}
}
This project includes optimized Zed configuration in .zed/settings.json
:
{
"format_on_save": "on",
"formatter": "ruff",
"linter": "ruff",
"tab_size": 4,
"languages": {
"Python": {
"format_on_save": "on",
"formatter": {
"external": {
"command": "uv",
"arguments": ["run", "ruff", "format", "-"]
}
}
}
}
}
- Django 5.2 with latest security patches
- CSP headers configured
- HTTPS redirect in production
- Secure cookie settings
- SQL injection protection via ORM
- XSS protection with template escaping
- CSRF protection enabled
- Security middleware stack
- Bandit security scanner in CI/CD
After setup, you're ready to:
- Create your first app:
uv run python manage.py startapp your_app
- Move it to apps directory:
mv your_app apps/
- Add to INSTALLED_APPS: Update
conf/settings/base.py
- Create models: Define your data structure
- Write tests first: TDD for the win
- Build APIs: Use the standardized response format
- Deploy with confidence: Follow the deployment checklist
This template stands on the shoulders of giants:
- Original foundation: fceruti/django-starter-project - The OG Django starter
- Enterprise inspiration: wemake-services/wemake-django-template - Serious business template
- Documentation style: FastAPI - Made docs fun again
- Modern tooling: Astral - UV and Ruff creators
- Dependabot: GitHub's automated dependency updates
MIT License - Use it, abuse it, make money with it. Just don't blame me when your startup becomes a unicorn and you forget to invite me to the IPO party.