django-models
Installation
SKILL.md
Django Model Patterns
Core Philosophy: Fat Models, Thin Views
Business logic belongs in models and managers, not views. Views orchestrate workflows; models implement domain behavior. This principle creates testable, reusable code that stays maintainable as complexity grows.
Good: Model methods handle business rules, state transitions, validation Bad: Views contain if/else logic for domain rules, calculate derived values
Model Design
Structure Your Models Around Domain Concepts
- Use
TextChoices/IntegerChoicesfor status fields and enums - Add
get_absolute_url()for canonical object URLs - Include
__str__()for readable representations - Set proper
orderingin Meta for consistent default sorting - Add database indexes for frequently filtered/sorted fields
- Use abstract base models for shared fields (timestamps, soft deletes, etc.)