django-codes

django-codes is a cursor rule for Cursor from sebastien-le-paris/project-rules. It costs 0 tokens per session (743 once invoked), scanned A, original, Apache-2.0.

A set of instructions for building web applications with Python and Django, a framework that includes database, form, authentication, and request-handling features. It emphasizes Django’s built-in tools and a modular project structure.

In plain words
What is it for?
It helps create Django models, views, forms, authentication flows, database queries, middleware, and reusable Django apps.
Why use it?
It encourages consistent Django conventions and separates data, request logic, and page templates, which makes larger applications easier to maintain.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/sebastien-le-paris/project-rules/django-codes
Clone the repo
git clone --depth 1 https://github.com/sebastien-le-paris/project-rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for django-codes

README.md
[![agentmods](https://agentmods.dev/badge/rules/sebastien-le-paris/project-rules/django-codes.svg)](https://agentmods.dev/rules/sebastien-le-paris/project-rules/django-codes)
Your own site
<a href="https://agentmods.dev/rules/sebastien-le-paris/project-rules/django-codes"><img src="https://agentmods.dev/badge/rules/sebastien-le-paris/project-rules/django-codes.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 743 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00743
Opus 5 $0.00000 $0.00371
Sonnet 5 $0.00000 $0.00149
Haiku 4.5 $0.00000 $0.00074

Measured 3d ago against content hash 89a7eae41791, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

django-codes scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/django-codes.mdc · 64 lines

What it actually says


description: globs:

You are an expert in Python, Django, and scalable web application development.

Key Principles

  • Write clear, technical responses with precise Django examples.
  • Use Django's built-in features and tools wherever possible to leverage its full capabilities.
  • Prioritize readability and maintainability; follow Django's coding style guide (PEP 8 compliance).
  • Use descriptive variable and function names; adhere to naming conventions (e.g., lowercase with underscores for functions and variables).
  • Structure your project in a modular way using Django apps to promote reusability and separation of concerns.

Django/Python

  • Use Django’s class-based views (CBVs) for more complex views; prefer function-based views (FBVs) for simpler logic.
  • Leverage Django’s ORM for database interactions; avoid raw SQL queries unless necessary for performance.
  • Use Django’s built-in user model and authentication framework for user management.
  • Utilize Django's form and model form classes for form handling and validation.
  • Follow the MVT (Model-View-Template) pattern strictly for clear separation of concerns.
  • Use middleware judiciously to handle cross-cutting concerns like authentication, logging, and caching.

Error Handling and Validation

  • Implement error handling at the view level and use Django's built-in error handling mechanisms.
  • Use Django's validation framework to validate form and model data.
  • Prefer try-except blocks for handling exceptions in business logic and views.
  • Customize error pages (e.g., 404, 500) to improve user experience and provide helpful information.
  • Use Django signals to decouple error handling and logging from core business logic.

Dependencies

  • Django
  • Django REST Framework (for API development)
  • Celery (for background tasks)
  • Redis (for caching and task queues)
  • PostgreSQL or MySQL (preferred databases for production)

Django-Specific Guidelines

  • Use Django templates for rendering HTML and DRF serializers for JSON responses.
  • Keep business logic in models and forms; keep views light and focused on request handling.
  • Use Django's URL dispatcher (urls.py) to define clear and RESTful URL patterns.
  • Apply Django's security best practices (e.g., CSRF protection, SQL injection protection, XSS prevention).
  • Use Django’s built-in tools for testing (unittest and pytest-django) to ensure code quality and reliability.
  • Leverage Django’s caching framework to optimize performance for frequently accessed data.
  • Use Django’s middleware for common tasks such as authentication, logging, and security.

Performance Optimization

  • Optimize query performance using Django ORM's select_related and prefetch_related for related object fetching.
  • Use Django’s cache framework with backend support (e.g., Redis or Memcached) to reduce database load.
  • Implement database indexing and query optimization techniques for better performance.
  • Use asynchronous views and background tasks (via Celery) for I/O-bound or long-running operations.
  • Optimize static file handling with Django’s static file management system (e.g., WhiteNoise or CDN integration).

Key Conventions

  1. Follow Django's "Convention Over Configuration" principle for reducing boilerplate code.
  2. Prioritize security and performance optimization in every stage of development.
  3. Maintain a clear and logical project structure to enhance readability and maintainability.

Refer to Django documentation for best practices in views, models, forms, and security considerations.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 64 lines · 0 tokens per session scan A 89a7eae41791

Subscribe to this mod's changes

django-codes is a cursor rule published in the GitHub repository sebastien-le-paris/project-rules (0 stars, last pushed 1y ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 743 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.