Skip to content

info.registration ​

Overview ​

Model registration for the meta-info API, mapping models to serializers and viewsets.

get_all_registrations ​

Get all the registrations.

:return: All the registrations.

Signature ​

get_all_registrations()

Source ​

server/vueda/info/registration.py:171

get_registered_content_types ​

Get all the registered content types.

:return: All the registered content types.

Signature ​

get_registered_content_types()

Source ​

server/vueda/info/registration.py:181

get_registration ​

Get the registration for a content type.

:param content_type: The content type to get the registration for. :return: The registration for the content type.

Signature ​

get_registration(content_type)

Parameters ​

NameTypeRequiredDefaultDescription
content_typeyes

Source ​

server/vueda/info/registration.py:138

get_serializer_for_model ​

Return the canonical serializer class registered for model, or None if the model has not been registered. Uses the in-process registry directly, avoiding the ContentType database query required by :func:get_registration.

Signature ​

get_serializer_for_model(model)

Parameters ​

NameTypeRequiredDefaultDescription
modelyes

Source ​

server/vueda/info/registration.py:160

register ​

Register a model so that it can be used with ModelInfoViewSet. You should do this in the ready method of an AppConfig, not as a side effect of importing viewsets or serializers.

Called with both arguments, it registers the model at once and returns canonical_viewset.

Called with only canonical_serializer, it registers nothing and returns a class decorator. Applying the decorator to a viewset class registers the serializer with that viewset and returns the class unchanged::

@register(OrderSerializer)
class OrderViewSet(VuedaViewSet):
    ...

The decorator form registers the model when Python imports the module that defines the viewset, so it takes effect only if something imports that module. To register a model without a viewset, use register_serializer.

:param canonical_serializer: The serializer to use as a reference for the model. Only a Meta.model is required; it does not need to inherit VuedaSerializer. The /info/ meta-API falls back to defaults for any VuedaExpandableFieldsSerializerMixin hooks (generate_expand_model_info, get_expand_model_info, get_field_model_info) that the serializer doesn't define. :param canonical_viewset: The viewset to use as a reference for the model. When omitted, the call returns the class decorator described above.

Signature ​

register(canonical_serializer, canonical_viewset)

Parameters ​

NameTypeRequiredDefaultDescription
canonical_serializeryes
canonical_viewsetnoNone

Source ​

server/vueda/info/registration.py:24

register_serializer ​

Register a model so that it can be used with ModelInfoViewSet. You should do this in the ready method of an AppConfig, not as a side effect of importing viewsets or serializers.

Because there is no viewset, the model info has no actions, filtering, or column totals, and its ordering metadata reports only the model's Meta.ordering default. Fields, expands, permissions, and the field choices endpoint work as they do for a model registered with a viewset. The filter choices endpoint answers 404, since there is no filterset.

:param canonical_serializer: The serializer to use as a reference for the model. Only a Meta.model is required; it does not need to inherit VuedaSerializer. The /info/ meta-API falls back to defaults for any VuedaExpandableFieldsSerializerMixin hooks (generate_expand_model_info, get_expand_model_info, get_field_model_info) that the serializer doesn't define.

Signature ​

register_serializer(canonical_serializer)

Parameters ​

NameTypeRequiredDefaultDescription
canonical_serializeryes

Source ​

server/vueda/info/registration.py:90

Source ​

server/vueda/info/registration.py