ModelInfoChoicesViewSet
Overview
This viewset is for providing metadata about field choices to front-end clients. This is a read-only viewset.
Effectively, this is a custom model viewset for content types.
get_queryset
Returns a queryset if the field is a relation. Return a list if the field is not a relation.
Signature
get_queryset(self)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes |
Source
server/vueda/info/viewsets.py:279
has_choices
Report whether a serializer field offers choices, without materializing them.
RelatedField.choices and ManyRelatedField.choices are properties that read the related queryset, so a plain hasattr on the instance reads the related table. Testing the class answers the same question for every DRF field without a query. The instance test stays for a field that assigns choices in __init__ instead of declaring a property.
Signature
has_choices(self, field)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| field | yes |
Source
server/vueda/info/viewsets.py:210
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
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes |
Source
server/vueda/info/viewsets.py:239
validate_queryset
Signature
validate_queryset(self, serializer, fields)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| self | yes | ||
| serializer | yes | ||
| fields | yes |
Source
server/vueda/info/viewsets.py:221
basename
description
detail
name
serializer_class
suffix
Source
server/vueda/info/viewsets.py:201