Skip to content

core.serializers ​

Overview ​

Serializer base classes combining flex-fields, nested writes, and validation.

Submodules ​

Classes ​

ensure_flex_fields_applied ​

Apply the request's query-param-driven expand/fields/omit resolution (_flex_options_rep_only) to serializer.fields. rest_flex_fields2 only applies this resolution automatically inside to_representation(); merely accessing .fields does not, because the get_fields() that triggers applies a separate, constructor-kwarg-driven options set (_flex_options_base) instead, which is empty for a serializer built the normal way from a request.

Needed by a caller that must inspect the resolved field tree -- which fields a request's ?e= actually turned into nested serializers -- without first serializing an instance, such as a queryset's prefetch plan (vueda.core.viewsets.build_prefetch_plan).

A no-op if this serializer instance already applied it, whether by a prior call here or by to_representation itself, so calling this before a representation happens does not double the expansion work or clobber fields that expansion already added to.

Signature ​

ensure_flex_fields_applied(serializer)

Parameters ​

NameTypeRequiredDefaultDescription
serializeryes

Source ​

server/vueda/core/serializers/__init__.py:185

Source ​

server/vueda/core/serializers/__init__.py