All API endpoints are registered in the root URL config
Use DRF serializers for all request/response shaping — no raw JsonResponse with hand-built dicts
Serializer output field names and nesting must match the frontend TypeScript types exactly
Validate business logic server-side before persisting — including constraints that cannot be expressed at DB level. Load and cache static config files at startup; do not re-read per request
DRF's OpenAPI schema generation is the source of truth for frontend type generation. Keep serializer field names, types, and nesting accurate
CORS is installed (corsheaders); ensure it is in MIDDLEWARE and configured before shipping any cross-origin endpoint
API auth is session-based (SessionAuthentication) with CSRF protection
User data isolation is mandatory: list endpoints must scope to request.user; object lookups must use user-filtered querysets
When a user requests another user's object ID, return 404 (not 403) so object existence is not leaked
Generic code must not reference concrete subclasses by name. A generic view handling all GlobalModel subclasses should depend only on the GlobalModel interface. Use explicit registries (dicts mapping model class → collaborator) or protocol attributes (filterable_fields, get_favorite_ids_for) to keep generic code decoupled
DEBUG must be False in production (DEBUG = not IS_PRODUCTION)
SECRET_KEY must be required in production — use os.environ['SECRET_KEY'] (no .get() fallback) so the server fails loudly rather than running with an insecure default
Never widen ALLOWED_HOSTS, CORS_ALLOWED_ORIGINS, or CSRF_TRUSTED_ORIGINS unconditionally — scope to known origins, add production hostnames via env vars gated on IS_PRODUCTION
Database config should switch on IS_PRODUCTION: SQLite for dev, Postgres for prod
Never add a setting required in production without either gating on IS_PRODUCTION or providing a safe non-functional dev default (empty string that disables the feature)
Optional integrations (OAuth, third-party APIs): read from os.environ.get('VAR', '') and degrade gracefully when absent
Testing
Every new API endpoint or serializer change → add or update tests
Pure helper functions → unit test with monkeypatch to decouple from real data files or configuration
Prefer the API client (client.post(...)) for request/response tests over direct ORM
Add new tests to the existing file covering the same module — do not create new cross-cutting test files
1---2name: shaoster-glaze-django-api3description: Django + DRF Conventions4---56# Django + DRF Conventions78## Stack910Django, Django REST Framework, SQLite (dev), django-cors-headers, drf-spectacular1112## Conventions1314- All API endpoints are registered in the root URL config15- Use DRF serializers for all request/response shaping — no raw `JsonResponse` with hand-built dicts16- Serializer output field names and nesting must match the frontend TypeScript types exactly17- Validate business logic server-side before persisting — including constraints that cannot be expressed at DB level. Load and cache static config files at startup; do not re-read per request18- DRF's OpenAPI schema generation is the source of truth for frontend type generation. Keep serializer field names, types, and nesting accurate19- CORS is installed (`corsheaders`); ensure it is in `MIDDLEWARE` and configured before shipping any cross-origin endpoint20- API auth is session-based (`SessionAuthentication`) with CSRF protection21- **User data isolation is mandatory:** list endpoints must scope to `request.user`; object lookups must use user-filtered querysets22- When a user requests another user's object ID, return `404` (not `403`) so object existence is not leaked23- **Generic code must not reference concrete subclasses by name.** A generic view handling all `GlobalModel` subclasses should depend only on the `GlobalModel` interface. Use explicit registries (dicts mapping model class → collaborator) or protocol attributes (`filterable_fields`, `get_favorite_ids_for`) to keep generic code decoupled2425## Production Settings Rules2627Gate dev/prod behavior on a single flag:28```python29IS_PRODUCTION = bool(os.environ.get('PRODUCTION', ''))30```3132- `DEBUG` must be `False` in production (`DEBUG = not IS_PRODUCTION`)33- `SECRET_KEY` must be **required** in production — use `os.environ['SECRET_KEY']` (no `.get()` fallback) so the server fails loudly rather than running with an insecure default34- Never widen `ALLOWED_HOSTS`, `CORS_ALLOWED_ORIGINS`, or `CSRF_TRUSTED_ORIGINS` unconditionally — scope to known origins, add production hostnames via env vars gated on `IS_PRODUCTION`35- Database config should switch on `IS_PRODUCTION`: SQLite for dev, Postgres for prod36- Never add a setting required in production without either gating on `IS_PRODUCTION` or providing a safe non-functional dev default (empty string that disables the feature)37- Optional integrations (OAuth, third-party APIs): read from `os.environ.get('VAR', '')` and degrade gracefully when absent3839## Testing4041- Every new API endpoint or serializer change → add or update tests42- Pure helper functions → unit test with `monkeypatch` to decouple from real data files or configuration43- Prefer the API client (`client.post(...)`) for request/response tests over direct ORM44- Add new tests to the existing file covering the same module — do not create new cross-cutting test files4546Run tests:47```bash48rtk bazel test //api:api_test49```5051---52> Source: [shaoster/glaze](https://github.com/shaoster/glaze) — distributed by [TomeVault](https://tomevault.io).53<!-- tomevault:4.0:skill_md:2026-05-22 -->
Run npx skillmds@latest add tomevault-io/shaoster-glaze-django-api in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Django + DRF Conventions It is listed under Integrations & APIs on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.