Home › Django › Django CLAUDE.md

Django CLAUDE.md

CLAUDE.md for Django 5 projects with DRF, pytest-django and PostgreSQL.

Claude Code (CLAUDE.md)Django

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

CLAUDE.mdDownload  
# CLAUDE.md — Django

## Commands
- Run: `uv run python manage.py runserver` · Tests: `uv run pytest` · Lint: `uv run ruff check . && uv run ruff format --check .`
- Migrations: `uv run python manage.py makemigrations <app>` then review the generated file before `migrate`.

## Conventions
- One Django app per bounded domain under `apps/`. Business logic in `services.py`/`selectors.py`, not in views or serializers.
- Fat models are fine for invariants; complex workflows go in services.
- DRF: explicit serializers with `fields = [...]` (never `"__all__"`), permission classes on every view.
- Query hygiene: `select_related`/`prefetch_related` for relations; check with `django-debug-toolbar` or `assertNumQueries` in tests.
- Settings split: `config/settings/{base,dev,prod}.py`; secrets from environment via `django-environ`.
- Never edit an applied migration; add a new one. Data migrations use `RunPython` with a reverse function.

## Don't
- Don't use raw SQL without parameters. Don't disable CSRF. Don't put logic in signals unless decoupling is required.

Related rules

AWS CDK (TypeScript) CLAUDE.md

CLAUDE.md for AWS CDK v2 apps in TypeScript: constructs, least-privilege grants, snapshot tests, and safe deploys.

Claude Code (CLAUDE.md)AWS CDK

Bun runtime CLAUDE.md

CLAUDE.md for TypeScript projects on Bun 1.2+: bun test, Bun.serve, built-in SQLite/Postgres, and bundling.

Claude Code (CLAUDE.md)Bun

Claude Agent SDK CLAUDE.md

CLAUDE.md for building agents with the Claude Agent SDK (Python/TypeScript): options, tools, permissions, and hooks.

Claude Code (CLAUDE.md)LLM apps & agents

Code reviewer subagent (Claude Code)

A Claude Code subagent definition that reviews the current diff for bugs, security, and tests, reporting by severity.

Claude Code (CLAUDE.md)Agent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.