Skip to content

...quite the OPINIONATED boilerplate for a Django project. Leverages UV for blazing-fast dependency management, Ruff for unified linting/formatting, MyPy for robust type safety, and Docker for consistent, containerized environments. Designed for speed, automation, and code quality.

License

Notifications You must be signed in to change notification settings

CynthiaWahome/django-starter-project

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Modern Django Starter Project

Quite the opionionated Django starter template

Python 3.12 Django 5.2 UV Ruff MyPy Dependabot Code style: Ruff

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! 😈

πŸŽ– Tool Choices

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.

πŸ“‹ Prerequisites (The Boring But Necessary Stuff)

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")

πŸš€ Getting Started

Method 1: Use This Template (Recommended for Humans)

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

Method 2 :One command to rule them all:

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

4) Run the project

You have two choices, either you turn every service on your own or you use docker-compose

A) Use Docker Compose

docker-compose up --build

Visit http://127.0.0.1:8000 and you'll see your site up and running πŸ§˜β€β™€οΈ

B) Run by yourself

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 πŸ§˜β€β™€οΈ

πŸ“ Project Structure (Organized Like Your Life Should Be)

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

🎯 API Standards (Because Consistency Is Beautiful)

All API endpoints follow a standardized response format:

Success Response

{
  "success": true,
  "message": "Data retrieved successfully",
  "data": {
    "user": {
      "id": 1,
      "email": "[email protected]",
      "created_at": "2025-01-01T00:00:00Z"
    }
  },
  "error": null,
  "metadata": {}
}

Error Response

{
  "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": {}
}

Paginated Response

{
  "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
    }
  }
}

♻️ Zed Editor Settings

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", "-"]
        }
      }
    }
  }
}

πŸ”’ Security Features (Because Hackers Don't Sleep)

  • 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

πŸŽ‰ What's Next? (Your Journey Begins)

After setup, you're ready to:

  1. Create your first app: uv run python manage.py startapp your_app
  2. Move it to apps directory: mv your_app apps/
  3. Add to INSTALLED_APPS: Update conf/settings/base.py
  4. Create models: Define your data structure
  5. Write tests first: TDD for the win
  6. Build APIs: Use the standardized response format
  7. Deploy with confidence: Follow the deployment checklist

πŸ™ Credits & Inspiration

This template stands on the shoulders of giants:

πŸ“„ License

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.

About

...quite the OPINIONATED boilerplate for a Django project. Leverages UV for blazing-fast dependency management, Ruff for unified linting/formatting, MyPy for robust type safety, and Docker for consistent, containerized environments. Designed for speed, automation, and code quality.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 72.5%
  • HTML 12.2%
  • Shell 6.0%
  • JavaScript 5.1%
  • Dockerfile 2.1%
  • SCSS 2.1%