Recipes¶
Task-shaped how-tos. Each one is self-contained and assumes you've read the Quickstart and Concepts.
- Custom action with
@service_action— add a non-CRUD action to a viewset and route it through the same validate-dispatch-render flow as the standard mutations. - Compose your own viewset — pick the per-
action mixins you actually need instead of starting from
ServiceViewSet. - Pass extra kwargs to services — surface a
tenant, a feature flag, or a test clock to your services without
threading it through
request. - Per-action permissions on the spec — set
permission_classesper action withoutif self.action == ...branching inget_permissions(). - Per-spec queryset shaping — add
select_related/prefetch_related/annotationsto a selector spec, plus anextend_querysetcallable for request-dependent shaping. - Customise serializer context — direction-
and action-specific hooks for
get_serializer_context(), so the input and output serializers can see different keys. - Scaffold a service app —
startserviceappand the convention behindservices/,selectors/,validators/.