Skip to content

ModelInfoChoicesBaseViewSet

Overview

Mixin for DRF ViewSets to add 'permitted_expands' in serializer context based on the current action. It utilizes 'permit_{action}_expands' attributes of the ViewSet to determine expandable fields for each action (e.g., list, retrieve).

This replaces rest_flex_fields.FlexFieldsMixin and rest_flex_fields.FlexFieldsModelViewSet usage.

init {#init}

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

Signature {#init-signature}

__init__(self, args, kwargs)

Parameters {#init-parameters}

NameTypeRequiredDescription
selfyes
argsyes
kwargsyes

Source {#init-source}

server/vueda/info/viewsets.py:108

canonical

Signature

canonical(unknown)

Parameters

NameTypeRequiredDescription
unknownyes

check_permissions

For fields: If the choices are hard coded on a field, then we check 'read' on the current model. If the choices are a foreign key then we check 'read' on the current model and 'list' on the related model.

For filters: If the choices are hard coded on the filter, then we check 'read' on the current model, because you may not be able to 'list' it. If the choices are a foreign key on the filter, then we check 'read' on the current model and 'list' on the related model.

If choices_permissions is None: The field carries choices but is neither a model field nor a relation, so there is no model to check against. An unknown field name never reaches this check, because resolve_choices raises Http404 for it first.

Signature

check_permissions(self, request)

Parameters

NameTypeRequiredDescription
selfyes
requestyes

Source

server/vueda/info/viewsets.py:136

dispatch

Dispatch the incoming request to the appropriate handler method.

This method implements the core request/response lifecycle for Django REST Framework views:

  1. Wraps the incoming Django HttpRequest in a REST framework Request.
  2. Performs content negotiation, authentication, permission, and throttling checks.
  3. Resolves and calls the appropriate HTTP method handler (e.g. get(), post(), put()).
  4. Handles any exceptions raised during processing and converts them into appropriate Response objects.
  5. Finalizes and returns the response with proper rendering and headers applied.

Signature

dispatch(self, request, app_label, model, field, args, kwargs)

Parameters

NameTypeRequiredDescription
selfyes
requestyes
app_labelyes
modelyes
fieldyes
argsyes
kwargsyes

Source

server/vueda/info/viewsets.py:165

get_content_type_instance

Signature

get_content_type_instance(self)

Parameters

NameTypeRequiredDescription
selfyes

Source

server/vueda/info/viewsets.py:190

get_formatted_name_lookup_expression

Signature

get_formatted_name_lookup_expression(self, queryset)

Parameters

NameTypeRequiredDescription
selfyes
querysetyes

Source

server/vueda/info/viewsets.py:182

initial

Runs anything that needs to occur prior to calling the method handler.

Signature

initial(self, request, args, kwargs)

Parameters

NameTypeRequiredDescription
selfyes
requestyes
argsyes
kwargsyes

Source

server/vueda/info/viewsets.py:172

resolve_choices

Resolve the addressed field, the permissions it requires, and the state that get_queryset needs to build the choices.

DRF calls check_permissions before it calls the handler, so resolution cannot wait for get_queryset. Subclasses store their resolved state on the instance, raise Http404 for a field the model does not offer, and tolerate repeat calls.

Signature

resolve_choices(self)

Parameters

NameTypeRequiredDescription
selfyes

Source

server/vueda/info/viewsets.py:125

choices_content_types

choices_resolved

filter_backends

object

permission_classes

queryset

serializer_class

Source

server/vueda/info/viewsets.py:102

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2