agentleFS
dekozadekoza/oh-my-slop/skills/reference/drf/SKILL.md

drf

Skill4 starsChanged 8 months agoUnlicenseView on GitHub

Use when building, securing, or fixing REST APIs with Django REST Framework (anything importing rest_framework). Triggers on: "DRF", "serializer", "ViewSet", "APIView", "router", "permission classes", "throttling", "pagination". Not for pure Django ORM/template/form/admin work — use django for those.

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill for DRF API implementation: serializers, views, viewsets, routers, authentication, permissions, throttling, filtering, …

    line 13
  2. Distinctive:

    Call out the critical DRF rules applied.

    line 71

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Django REST Framework Reference

Use this skill for DRF API implementation: serializers, views, viewsets, routers, authentication, permissions, throttling, filtering, pagination, testing, and configuration. Apply the critical rules below, then route to the reference files the task needs.

Critical Rules

  1. fields or exclude is mandatory — Since v3.3.0, ModelSerializer.Meta MUST declare fields or exclude. Omitting both raises ImproperlyConfigured.
  2. Writable nested representations require explicit code — ModelSerializer.create() and .update() do NOT support writable nested serializers by default. You must override these methods.
  3. Reverse relations are NOT auto-included — ModelSerializer and HyperlinkedModelSerializer do not include reverse FK/M2M fields. Add them explicitly to fields.
  4. M2M with through model defaults to read-only — Relational fields targeting ManyToManyField with a through model are automatically read_only=True.
  5. Object-level permissions skip creation — has_object_permission() is NOT called during object creation (POST). Restrict creation in perform_create() or the serializer.
  6. Permission composition precedence — ~ highest, then &, then |. Use parentheses to be explicit.
  7. HiddenField disappears in partial updates — HiddenField() does not appear in partial=True serializers (PATCH requests).
  8. UniqueTogetherValidator treats fields as required — All fields in a UniqueTogetherValidator are implicitly required=True, except those with default values.
  9. ViewSet action unavailable in early methods — self.action is NOT set when get_parsers, get_authenticators, or get_content_negotiator are called.
  10. No trailing slash in router register() prefix — Routers append slashes automatically. router.register(r'users', ...) not r'users/'.
  11. Throttling uses non-atomic cache operations — Race conditions possible under high concurrency. Not a security measure against brute force.
  12. CursorPagination defaults to -created ordering — Models MUST have a created field, or override the ordering attribute.
  13. Request uses composition, not inheritance — DRF Request wraps Django HttpRequest via composition. Access standard attributes via request.META, request.session etc.
  14. extra_kwargs silently ignored for explicit fields — If you declare a field on the serializer class AND have extra_kwargs for it, the extra_kwargs do nothing.
  15. Serializer relations cause N+1 queries — Nested and related serializer fields fire one query per object during list serialization. Pair every list-returning view with select_related/prefetch_related on its queryset (django-discipline's ORM rule applies to DRF views too).

When Not To Use This Skill

  • Pure Django ORM/views/templates — Load django for models, querysets, template rendering, forms, admin, or middleware outside rest_framework.
  • FastAPI / Django Ninja APIs — This skill is rest_framework-only; do not apply DRF patterns to other API frameworks.
  • HTMX interaction flows — For partial rendering, swaps, triggers, load htmx.
  • Tabler UI work — For Tabler components and CSS patterns, load tabler.
  • HTTP status code deep semantics — For 400 vs 422, 401 vs 403, redirect codes, load http-status-codes.
  • Project-specific business rules — Load the project's custom skill.

Routing

Choose the primary reference; add one secondary reference only when the task clearly crosses domains. Keep the answer grounded in the reference files actually used.

Single-domain (one file):

Use forFile
Serializer hierarchy, field types, relations, validators, nested writesreferences/serializers-fields.md
APIView, generics, mixins, viewsets, @action, routersreferences/views-viewsets.md
Authentication, permissions, throttlingreferences/auth-permissions.md
Filter backends, search, ordering, paginationreferences/filtering-pagination.md
Request, Response, exceptions, status codesreferences/requests-responses.md
Parsers, renderers, negotiation, metadatareferences/parsers-renderers.md
Test utilities, complete settings referencereferences/testing-settings.md
Dispatch flow, parsing pipeline, versioning, schemasreferences/internals.md

Cross-domain (two files):

  • Full CRUD API → views-viewsets.md + serializers-fields.md
  • Secured API → auth-permissions.md + views-viewsets.md
  • Filtered/paginated lists → filtering-pagination.md + views-viewsets.md
  • Custom content handling → parsers-renderers.md + requests-responses.md
  • Serializer with permissions → serializers-fields.md + auth-permissions.md

Output Expectations

  • Name the reference files used.
  • State the minimum tests or verification steps.
  • Call out the critical DRF rules applied.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.