---
url: "https://vueda.dev/v3/reference/api/py/vueda.core.viewsets/NoExtraFieldsForViewSetMixin.md"
title: "NoExtraFieldsForViewSetMixin"
---

# NoExtraFieldsForViewSetMixin

## Overview

Mixin for DRF ViewSets that raises a VuedaValidationError (400) for any query parameter `list` or
`retrieve` does not recognize.

`list` recognizes filterset fields (from `filterset_class`, when declared) plus pagination,
ordering, search, column totals, and REST Flex Fields params (`get_extra_allowed_fields()`). A
viewset with no `filterset_class` recognizes only the latter set. `retrieve` recognizes only the
expand, fields and omit params -- column totals are a `list` concept, so the totals param is
rejected there.

## `get_extra_allowed_fields` {#get_extra_allowed_fields}

The query parameters ``list`` recognizes beyond this viewset's filterset fields.

The totals parameter is among them only when something on this viewset reads it. It is
``ListRowLevelViewSetMixin.list`` that validates the names it carries and answers 400 for an
undeclared one, so on a viewset without that mixin recognizing the parameter would mean
accepting any value for it and doing nothing, which is the one thing this mixin exists to
prevent.

The test is whether the mixin is present, not whether ``list`` actually reaches it. A
subclass that overrides ``list`` and never delegates still recognizes the parameter and then
ignores it. That case is left alone deliberately: an override calling ``super().list()`` is
ordinary and does read the parameter, and nothing here can tell the two apart.

### Signature {#get_extra_allowed_fields-signature}

`get_extra_allowed_fields(self)`

#### Parameters {#get_extra_allowed_fields-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |

### Source {#get_extra_allowed_fields-source}

`server/vueda/core/viewsets/__init__.py:1284`

## `get_retrieve_allowed_fields` {#get_retrieve_allowed_fields}

### Signature {#get_retrieve_allowed_fields-signature}

`get_retrieve_allowed_fields()`

### Source {#get_retrieve_allowed_fields-source}

`server/vueda/core/viewsets/__init__.py:1312`

## `list` {#list}

### Signature {#list-signature}

`list(self, request, args, kwargs)`

#### Parameters {#list-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="list-param-request">request</span> |  | yes |  |  |
| <span id="list-param-args">args</span> |  | no |  |  |
| <span id="list-param-kwargs">kwargs</span> |  | no |  |  |

### Source {#list-source}

`server/vueda/core/viewsets/__init__.py:1411`

## `reject_unrecognized_query_params` {#reject_unrecognized_query_params}

### Signature {#reject_unrecognized_query_params-signature}

`reject_unrecognized_query_params(request, valid_fields, message_fields)`

#### Parameters {#reject_unrecognized_query_params-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="reject_unrecognized_query_params-param-request">request</span> |  | yes |  |  |
| <span id="reject_unrecognized_query_params-param-valid_fields">valid_fields</span> |  | yes |  |  |
| <span id="reject_unrecognized_query_params-param-message_fields">message_fields</span> |  | no | `None` |  |

### Source {#reject_unrecognized_query_params-source}

`server/vueda/core/viewsets/__init__.py:1320`

## `retrieve` {#retrieve}

### Signature {#retrieve-signature}

`retrieve(self, request, args, kwargs)`

#### Parameters {#retrieve-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="retrieve-param-request">request</span> |  | yes |  |  |
| <span id="retrieve-param-args">args</span> |  | no |  |  |
| <span id="retrieve-param-kwargs">kwargs</span> |  | no |  |  |

### Source {#retrieve-source}

`server/vueda/core/viewsets/__init__.py:1402`

## `validate_flex_expand_and_field_param` {#validate_flex_expand_and_field_param}

Reject each ``f`` and ``e`` value the serializer cannot render or expand.

``list``, ``retrieve``, ``create``, and ``update`` (which ``partial_update`` calls) run this
check. A write runs it before the body is validated, so a rejected request saves nothing.

Every invalid name in both parameters goes into one error, keyed by the name. A name invalid
in both parameters carries both messages.

:param request: The request whose ``f`` and ``e`` query values are checked.
:param serializer: The action's serializer, built with the action's serializer context. It
    is the serializer that renders the response.
:raises VuedaValidationError: When an ``f`` value is not a valid field or wildcard, or an ``e``
    value is not a permitted expand or wildcard.

### Signature {#validate_flex_expand_and_field_param-signature}

`validate_flex_expand_and_field_param(request, serializer)`

#### Parameters {#validate_flex_expand_and_field_param-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="validate_flex_expand_and_field_param-param-request">request</span> |  | yes |  |  |
| <span id="validate_flex_expand_and_field_param-param-serializer">serializer</span> |  | yes |  |  |

### Source {#validate_flex_expand_and_field_param-source}

`server/vueda/core/viewsets/__init__.py:1333`

## Source

`server/vueda/core/viewsets/__init__.py:1272`
