---
name: django-rest-builder
description: "Django + DRF: serializers, viewsets, permissions, throttling, async views — production REST APIs. Scaffolds Django REST APIs with DRF serializers/viewsets, permissions, JWT or token auth, throttling, and OpenAPI docs."
license: MIT
---

# Django REST Builder

Django REST Builder scaffolds production-grade REST APIs on top of Django and Django REST Framework. It generates the serializers, viewsets, routers, permission classes, auth wiring, throttling, and OpenAPI schema you'd otherwise hand-write for every new app — following DRF conventions rather than a bespoke abstraction. It's aimed at backend and full-stack developers who already know Django and want a correct, opinionated starting point instead of copy-pasting boilerplate across projects.

## When to use it

- You're adding a new resource to an existing DRF project and want a `ModelSerializer` + `ModelViewSet` + router registration in one pass.
- You're standing up a fresh API and need JWT or token auth, per-view throttling, and Swagger/Redoc docs configured coherently.
- You want consistent permission patterns (`IsAuthenticated`, object-level checks, role gates) across many endpoints.
- You need an async view for an I/O-bound endpoint and want it wired correctly under ASGI.

## What it does

- **Serializers** — generates `serializers.ModelSerializer` subclasses with explicit `fields`, nested relations, `read_only_fields`, and `SerializerMethodField` stubs where appropriate.
- **Viewsets & routers** — produces `ModelViewSet` / `ReadOnlyModelViewSet` classes and registers them with `DefaultRouter` in `urls.py`.
- **Auth** — wires `rest_framework_simplejwt` (`TokenObtainPairView`, `TokenRefreshView`) or DRF's `TokenAuthentication`, including `DEFAULT_AUTHENTICATION_CLASSES`.
- **Permissions & throttling** — sets `DEFAULT_PERMISSION_CLASSES`, custom `BasePermission` subclasses, and scoped `ScopedRateThrottle` / `UserRateThrottle` with rates in `DEFAULT_THROTTLE_RATES`.
- **OpenAPI docs** — configures `drf-spectacular` (`SpectacularAPIView`, Swagger UI, Redoc).
- **Async views** — scaffolds `async def` views compatible with ASGI for non-blocking endpoints.

## Usage

```bash
curl -fsSL --create-dirs -o ~/.claude/skills/django-rest-builder/SKILL.md https://claudeskil.com/skills/django-rest-builder/SKILL.md

# then, inside your Django project:
"Build a REST API for the Order model with JWT auth, owner-only
write permissions, and 100/day throttling, plus Swagger docs."
```

Produces a serializer, a `ModelViewSet`, router registration, an `IsOwnerOrReadOnly` permission, throttle config, and a `/api/schema/` + `/api/docs/` route.

## Tips & gotchas

- SimpleJWT tokens are stateless — add `rest_framework_simplejwt.token_blacklist` to `INSTALLED_APPS` and run migrations if you need logout/revocation.
- Async DRF views can't call the ORM synchronously; wrap queries in `sync_to_async` or use async ORM methods (`aget`, `acreate`), and run under an ASGI server like Uvicorn/Daphne.
- `ScopedRateThrottle` needs a `throttle_scope` attribute on the view plus a matching key in `DEFAULT_THROTTLE_RATES`, or throttling silently no-ops.
- Regenerate the schema after model changes; drf-spectacular reads annotations, so add `@extend_schema` for non-obvious request/response shapes.

## FAQ

**JWT or token auth — which does it scaffold?** Either. Default is SimpleJWT (access/refresh pairs); ask for DRF `TokenAuthentication` if you want simple opaque tokens instead.

**Does it touch my existing settings?** It edits `INSTALLED_APPS` and the `REST_FRAMEWORK` dict additively and shows a diff before applying.

**Postgres-specific?** It targets Postgres for `ArrayField`/`JSONField` and indexes, but the generated DRF code runs on any Django-supported database.
