rest_flex_fields2.views.FlexFieldsMixin

class rest_flex_fields2.views.FlexFieldsMixin

View mixin that restricts which fields may be expanded on list actions.

Set permit_list_expands to a list of field names that are allowed to be expanded when the view is handling a list request. The allowed names are passed to the serializer via context['permitted_expands'] so that FlexFieldsSerializerMixin can enforce the constraint.

permit_list_expands: list[str] = []
action: str | None = None
get_serializer_context() dict[str, Any]

Extend the serializer context with permitted_expands for list actions.

When the current action is list, adds context['permitted_expands'] populated from permit_list_expands so the serializer can restrict expansion accordingly.