Types¶
SelectorSpec¶
SelectorSpec
dataclass
¶
Bases: Generic[ResultT, ExtraT]
All wiring for a single read action in one record.
Used as a value in action_specs on viewsets and as the spec=
argument to :class:SelectorListView / :class:SelectorRetrieveView.
Generic parameters (both default to Any):
ResultT— the selector's return type.ExtraT— aTypedDictdescribing the keys returned bykwargs.
Fields:
selector— callable invoked byget_queryset()(list) orget_object()(retrieve).Nonemeans "use the configuredqueryset/ default DRF behaviour".output_serializer— DRFSerializersubclass used byget_serializer_class()for this action.Nonefalls back to DRF's standardserializer_class.kwargs— callable returning extra kwargs to merge into the pool the selector receives. Co-locating it with the spec lets each action declare its own contract — noif self.action == ...branching in a catch-allget_selector_kwargs.
ServiceSpec¶
ServiceSpec
dataclass
¶
Bases: Generic[InputT, ResultT, ExtraT]
All wiring for a single mutation action in one record.
Used as a value in ServiceViewSet.service_specs and as the spec=
argument to :func:service_action / :class:ServiceCreateView /
:class:ServiceUpdateView / :class:ServiceDeleteView.
Generic parameters are optional and purely informational for type checkers:
InputT— the validated-data type produced byinput_serializer. For dataclass-based serializers this is the dataclass; for plainModelSerializerit is typicallydict[str, Any].ResultT— the value returned by the service callable, the input tooutput_selector(when set), and the value rendered byoutput_serializer.ExtraT— aTypedDictdescribing the keys returned bykwargs.
All three default to Any, so ServiceSpec(service=fn) keeps working
unchanged.
Fields mirror the kwargs that MutationFlowMixin._run_mutation
forwards to the underlying flow runner. success_status is left as
None so each consumer can supply its own action-appropriate default
(201 for create, 200 for update, 204 for destroy).
kwargs is a callable that returns extra kwargs to merge into the
pool the service receives. Co-locating it with the spec lets each action
declare its own contract — no if self.action == ... branching in a
catch-all get_service_kwargs. See :class:ServiceView for the
attributes available on the view argument.
ChangeResult¶
ChangeResult
dataclass
¶
Outcome of a mutation helper call.
instance is the model instance after the mutation. created is True
iff this came from :func:create_from_input / :func:acreate_from_input.
changes records every field whose value actually differed from its
prior value (or from UNSET for creates).
FieldChange¶
FieldChange
dataclass
¶
One field's before/after pair from a mutation.
old will be UNSET for fields populated as part of a create
(no prior value existed).
UNSET¶
unset ¶
The UNSET sentinel.
Used to distinguish "field omitted from input" from "field explicitly set to
None". Critical for partial updates where None must not stomp on an
existing value.