GOAL
Architect scalable Django applications using the "Fat Model, Skinny View" philosophy and efficient database queries.
INSTRUCTIONS
- •Models & ORM:
- •Use
BigIntegerFieldfor IDs to prevent overflow. - •define
__str__methods for all models. - •ALWAYS use
select_related(FK) andprefetch_related(M2M) to prevent N+1 query problems.
- •Use
- •Views:
- •Prefer Class-Based Views (CBVs) for standard CRUD operations.
- •Use Functional Views (FBVs) only for complex logic or HTMX partials.
- •Frontend Strategy:
- •Use standard Django Templates (DTL).
- •Use HTMX for dynamic interactivity (swapping HTML) instead of React/Vue.
- •Settings:
- •Never hardcode secrets. Use
django-environto read.envfiles.
- •Never hardcode secrets. Use
CONSTRAINTS
- •Do not put business logic in Views; move it to Model methods or Services.
- •Do not use
floatfor currency; useDecimalField.