Track
Django
Review URL patterns, models, QuerySets, forms, views, CSRF, settings, transactions, and tests.
- 01
URL pattern order
Put specific URL patterns before broad dynamic patterns so Django routes requests to the intended view.
urlsroutingorder - 02
Model fields and constraints
Use precise fields, validation intent, and database constraints so the model protects real domain rules.
modelsconstraintsfields - 03
QuerySets and lazy evaluation
Compose QuerySets before evaluation and load relationships intentionally to avoid hidden N+1 queries.
querysetsormperformance - 04
Model manager boundaries
Put common query rules in QuerySet or manager methods so views do not repeat domain filters.
modelsmanagersquerysets - 05
Forms and validation
Use forms or ModelForms to validate request data before creating or updating model instances.
formsvalidationviews - 06
Class-based view responsibilities
Keep class-based views focused on HTTP orchestration and move query or side-effect-heavy work behind named methods.
viewscbvresponsibility - 07
CSRF and unsafe methods
Protect state-changing requests with Django's CSRF flow instead of exempting views for convenience.
csrfsecurityforms - 08
Settings by environment
Load sensitive and environment-specific settings from the environment instead of hard-coding production behavior.
settingssecuritydeployment - 09
Transactions and side effects
Wrap related database writes in atomic transactions and run external side effects after commit.
transactionsatomicside effects - 10
Test client and fixtures
Use Django's test client with realistic data setup and assertions that cover status, template, and database changes.
testsclientfixtures