Django
CLAUDE.md for Django + DRF
Puntuación: AA CLAUDE.md encoding thin viewsets, the cross-app services boundary, and the migration-review habit that prevents dropped columns.
# CLAUDE.md - Registry (Django + DRF) ## Commands ```bash uv run python manage.py runserver # dev on :8000 uv run pytest apps/orders -k test_create # scope while iterating; full run is slow uv run ruff check . && uv run ruff format . uv run python manage.py makemigrations # after model edits; review the output ``` ## Architecture - One app per bounded context under `apps/`; each app is models → services → serializers → views, dependencies flowing left. - Views are thin DRF viewsets; anything conditional beyond permissions and serializer choice belongs in `services.py`. - Cross-app calls go through the target app's `services.py`, never its models - that boundary is what keeps apps extractable. ## Conventions - Serializers validate everything inbound; `request.data` is never read raw. - Query efficiency is enforced: use `select_related`/`prefetch_related` and keep the assertNumQueries assertions in tests passing. - New endpoints copy the shape of `apps/orders/views.py` (permissions, filterset, pagination). ## Workflow - Model change: edit, `makemigrations`, read the generated migration before applying - autogeneration happily drops columns. - Slow test hunt: `uv run pytest --durations=10`. ## Do not - Do not edit applied migrations; write a follow-up. - Do not import another app's models directly; use its service functions. - Do not silence the N+1 test assertions by raising the query budget.
Estos ejemplos se publican bajo CC0: úsalos libremente, sin atribución. Se proveen tal cual, sin garantía de ningún tipo: revísalos y adáptalos a tu proyecto antes de usarlos, ya que eres responsable del resultado de aplicarlos.
Lleva PromptArch a tu equipo
Implementa PromptArch como herramienta interna en cada área de tu empresa. Obtén cuentas de equipo con créditos precargados compartidos y dominios personalizados para tu organización.
Contáctanos