Skip to content

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_classes per action without if self.action == ... branching in get_permissions().
  • Per-spec queryset shaping — add select_related / prefetch_related / annotations to a selector spec, plus an extend_queryset callable 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 appstartserviceapp and the convention behind services/, selectors/, validators/.