Forge API
Overview
Use Forge's REST API framework to build CRUD endpoints with ViewSets and serializers.
When to Use
- •The task mentions serializers, viewsets, API routers, or REST endpoints.
- •You need CRUD APIs for Forge models.
- •The user asks about auth, permissions, filtering, ordering, or pagination for APIs.
Quick Start
- •Create a serializer defining exposed fields.
- •Create a ViewSet bound to a QuerySet and model.
- •Register the ViewSet on an API router and mount it on the server router.
Common Tasks
- •Add filtering, ordering, and pagination defaults.
- •Customize read-only fields and validation in serializers.
- •Organize routes with versioned API base paths.
Gotchas
- •Keep serializer fields aligned with model fields after changes.
- •Router base path affects all endpoint URLs.
- •Re-run
forge generatewhen model changes affect QuerySets or types.