CursorDjangoSecurity

Django Cursor Rules

Cursor rules for Django: security settings, ORM best practices, performance patterns, and production Django configuration.

.cursorrules
- Use select_related() and prefetch_related() to avoid N+1 query problems
- Keep business logic in service functions, not in views or models
- Always use Django's ORM; avoid raw SQL except for complex aggregations
- Use Django's CSRF protection; never exempt views without explicit justification
- Store secrets in environment variables, never in settings.py
- Use custom user model from project start; migrating later is painful
- Add __str__ and get_absolute_url to all models
- Use django-extensions and django-debug-toolbar in development

How to use with Cursor

Create a `.cursorrules` file in your project root and paste these rules. Cursor reads this automatically on every AI interaction.

#django#python#orm#security#cursor#coding-rules

Related Rules