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

# VuedaSerializer

## Overview

Standard serializer base for all VUEDA models. Combines extra-field rejection,
flex-fields expansion, writable nested relations, and an ``available_actions``
field that exposes permitted actions for the current user.

## `Meta` {#Meta}

### Source {#Meta-source}

`server/vueda/core/serializers/__init__.py:1092`

## `build_standard_field` {#build_standard_field}

Accept ``null`` for a file or image column that the model marks ``blank=True``.

DRF only allows ``null`` for a ``null=True`` column, and Django file columns are rarely nullable,
so an optional file had no value that means "no file". Accepting ``null`` lets a form send its empty
value, and lets a client clear a stored file. Django saves the cleared file as an empty name.

### Signature {#build_standard_field-signature}

`build_standard_field(self, field_name, model_field)`

#### Parameters {#build_standard_field-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="build_standard_field-param-field_name">field_name</span> |  | yes |  |  |
| <span id="build_standard_field-param-model_field">model_field</span> |  | yes |  |  |

### Source {#build_standard_field-source}

`server/vueda/core/serializers/__init__.py:1079`

## `create` {#create}

We have a bit of extra checking around this in order to provide
descriptive messages when something goes wrong, but this method is
essentially just:

    return ExampleModel.objects.create(**validated_data)

If there are many to many fields present on the instance then they
cannot be set until the model is instantiated, in which case the
implementation is like so:

    example_relationship = validated_data.pop('example_relationship')
    instance = ExampleModel.objects.create(**validated_data)
    instance.example_relationship = example_relationship
    return instance

The default implementation also does not handle nested relationships.
If you want to support writable nested relationships you'll need
to write an explicit `.create()` method.

### Signature {#create-signature}

`create(self, validated_data)`

#### Parameters {#create-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="create-param-validated_data">validated_data</span> |  | yes |  |  |

### Source {#create-source}

`server/vueda/core/serializers/__init__.py:1035`

## `get_field_model_info` {#get_field_model_info}

Customization hook for the ``model_fields`` metadata the ``/info/`` meta-API returns for this
serializer. Receives the generated field metadata dict (keyed by field name) and must return a
dict in the same shape; override to correct or add entries, such as the real type of a
``SerializerMethodField``. The default implementation applies ``field_display_choices``.

### Signature {#get_field_model_info-signature}

`get_field_model_info(self, fields)`

#### Parameters {#get_field_model_info-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="get_field_model_info-param-fields">fields</span> |  | yes |  |  |

### Source {#get_field_model_info-source}

`server/vueda/core/serializers/__init__.py:1008`

## `get_fields` {#get_fields}

Return fields after applying constructor-sourced flex-fields options.

### Signature {#get_fields-signature}

`get_fields(self)`

#### Parameters {#get_fields-parameters}

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

### Source {#get_fields-source}

`server/vueda/core/serializers/__init__.py:1000`

## `get_warnings` {#get_warnings}

Return advisory warnings for the current create/update as a mapping of
``{field_name: [messages], "non_field_errors": [messages]}``. An empty mapping means no
warnings.

Override to surface non-blocking concerns the user should confirm before the write commits
(for example, "this will deactivate the last administrator"). This is called by the viewset
after validation succeeds, so ``self.validated_data`` is populated and ``self.instance`` holds
the current (pre-save) instance on updates. It must not raise: blocking conditions belong in
``validate``/``VuedaValidationError`` (which return 400), whereas warnings gate the save behind
an explicit client confirmation (see ``WarningConfirmationMixin``).

### Signature {#get_warnings-signature}

`get_warnings(self)`

#### Parameters {#get_warnings-parameters}

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

### Source {#get_warnings-source}

`server/vueda/core/serializers/__init__.py:1041`

## `to_representation` {#to_representation}

Drops ``available_actions`` from ``self.fields`` before rendering when a client hasn't
named it through ``?f=``, rather than computing it and discarding the result afterward.
Unlike an ordinary field, ``available_actions`` is not part of the default response -- a
client must ask for it explicitly -- and computing it runs a permission check per CRUD
action and per extra action, so a response that will drop it anyway must not pay for it.

### Signature {#to_representation-signature}

`to_representation(self, instance)`

#### Parameters {#to_representation-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="to_representation-param-instance">instance</span> |  | yes |  |  |

### Source {#to_representation-source}

`server/vueda/core/serializers/__init__.py:1056`

## `update` {#update}

### Signature {#update-signature}

`update(self, instance, validated_data)`

#### Parameters {#update-parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| self |  | yes |  |  |
| <span id="update-param-instance">instance</span> |  | yes |  |  |
| <span id="update-param-validated_data">validated_data</span> |  | yes |  |  |

### Source {#update-source}

`server/vueda/core/serializers/__init__.py:1038`

## `available_actions` {#available_actions}

## `formatted_name` {#formatted_name}

## `object_revision` {#object_revision}

## `serializer_field_mapping` {#serializer_field_mapping}

## Source

`server/vueda/core/serializers/__init__.py:982`
