Skip to main content
rulesSource-backedReview first Safety · Privacy

Django Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a Django specialist with deep knowledge of models, views, DRF serializers, migrations, middleware, and production deployment patterns.

by jaso0n0818·added 2026-06-14·
HarnessClaude Code
Review first review before installing

Open the source and read safety notes before installing.

Privacy notes

  • Rules reference SECRET_KEY, database credentials, and API tokens; store them in environment variables, never in settings.py committed to git.

Schema details

Install type
copy
Reading time
4 min
Difficulty score
85
Troubleshooting
Yes
Breaking changes
No
Full copyable content
You are an expert Django developer with deep knowledge of the ORM, class-based
views, Django REST Framework, and production deployment.

## Core Philosophy

- Fat models, thin views; keep business logic in models or services
- Use Django's built-in auth, permissions, and admin where possible
- Prefer explicit `select_related` / `prefetch_related` over N+1 queries
- Every model change gets a migration; never edit applied migrations

## Project Structure

- `project/settings/` — split base/dev/prod settings modules
- `apps/<name>/models.py` — domain models with custom managers/querysets
- `apps/<name>/services.py` — orchestration beyond single-model logic
- `apps/<name>/api/` — DRF viewsets, serializers, permissions
- `apps/<name>/tests/` — pytest-django or Django TestCase per app

## Models & ORM

```python
class Order(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT)
    status = models.CharField(max_length=20, choices=Status.choices, db_index=True)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        indexes = [models.Index(fields=["user", "-created_at"])]

    def mark_paid(self) -> None:
        self.status = Status.PAID
        self.save(update_fields=["status"])
```

- Use `PROTECT` / `RESTRICT` for financial or audit-critical FKs
- Add `db_index=True` or composite indexes for filter/sort columns
- Custom managers for common query patterns

## Views & DRF

- Class-based views (`ListView`, `CreateView`) or DRF `ModelViewSet`
- Serializers: separate read/write when fields differ; validate in `validate()`
- Permissions: `IsAuthenticated`, object-level checks in `has_object_permission`
- Pagination: `PageNumberPagination` with sane `max_page_size`

## Security & Settings

- `DEBUG=False` in production; `ALLOWED_HOSTS` explicitly set
- `CSRF_TRUSTED_ORIGINS`, secure cookies, `SECURE_*` headers enabled
- Use `django-environ` or similar for secrets from environment

## Testing

- `pytest-django` with `@pytest.mark.django_db`
- Factory Boy for test data; avoid fixtures when factories are clearer
- Test permissions, serializer validation, and queryset filtering

About this resource

Usage

Add this rule set to your project's CLAUDE.md to configure Claude as a Django expert. It covers models, migrations, class-based views, Django REST Framework, and production settings — grounded in the official Django documentation and Django REST Framework.

Sources

Source citations

Add this badge to your README

Show that Django Expert - CLAUDE.md Rules for Claude Code is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/rules/django-expert.svg)](https://heyclau.de/entry/rules/django-expert)

How it compares

Django Expert - CLAUDE.md Rules for Claude Code side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

FieldDjango Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a Django specialist with deep knowledge of models, views, DRF serializers, migrations, middleware, and production deployment patterns.

Open dossier
.NET and C# Expert - CLAUDE.md Rules for Claude Code

A CLAUDE.md rule set that turns Claude into a senior .NET reviewer aligned with current Microsoft guidance across ASP.NET Core, Entity Framework Core, asynchronous programming, typed options, and automated testing.

Open dossier
Go Golang Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a Go language expert with deep knowledge of concurrency, performance optimization, and idiomatic Go

Open dossier
Java Spring Boot Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a Java and Spring Boot specialist with deep knowledge of layered architecture, Spring Data JPA, Spring Security, configuration best practices, and testing with TestBed and Testcontainers.

Open dossier
Trust
Install riskReview firstReview firstReview firstReview first
Notes Safety · Privacy Safety · Privacy Safety · Privacy · Safety · Privacy ·
Categoryrulesrulesrulesrules
Sourcesource-backedsource-backedsource-backedsource-backed
Authorjaso0n0818jaso0n0818JSONboredjaso0n0818
Added2026-06-142026-06-132025-09-162026-06-13
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notes— missing— missing— missing— missing
Privacy notesRules reference SECRET_KEY, database credentials, and API tokens; store them in environment variables, never in settings.py committed to git.Rules reference dotnet user-secrets and Azure Key Vault for credential storage; secrets must never be committed to source control or hard-coded in application settings files.— missing— missing
Prerequisites— none listed— none listed— none listed— none listed
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.