Full standards in python-django.md. Always-on summary:
Project structure:
- Split settings into
settings/base.py,settings/local.py,settings/production.py - One app per domain concept — never put all models in a single
models.pymonolith - Use
apps/subdirectory; register apps with dotted pathapps.users.apps.UsersConfig
Models and ORM:
- Always define
__str__,class Metawithordering, and explicitrelated_nameon FK/M2M - Use
select_related('user', 'product')for FK traversal,prefetch_relatedfor reverse/M2M — never N+1 - Wrap multi-step writes in
transaction.atomic(); useselect_for_update()for locking
DRF serializers:
- Use
ModelSerializerwith explicitfields = [...]— never use the magic all-fields shorthand - Validate in
validate_<field>orvalidate(); raiseserializers.ValidationError - Use
SerializerMethodFieldfor computed read-only fields
Views/URLs:
- Prefer
APIVieworViewSet+DefaultRouterfor REST endpoints - Use
permission_classesandauthentication_classesexplicitly per view - Keep URL patterns in
urls.pyper app;include()them from the rooturls.py
Migrations:
- Never edit migration files by hand; use
makemigrations --name <descriptive-name> - Add
db_index=Truevia the model field, not raw SQL migrations - Provide
reversefunctions inRunPythonmigrations or markatomic=Falsecarefully
Never:
- Never use
print()— uselogging.getLogger(__name__) - Never put secrets in
settings/base.py— useenvironordjango-environ - Never use broad exception catches — always catch the specific exception type or re-raise
Related skills: error-handling, logging-standards, database-sql, api-conventions
Source: manikumarkv/devrunway-claude-plugin — distributed by TomeVault.