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

# UserSerializer

## Overview

This is a public API, don't just change it without considering the impact.

This is used to list, create, update, and delete users.

## `Meta` {#Meta}

### Source {#Meta-source}

`server/vueda/user/serializers.py:133`

## `__init__` {#--init--}

Initialize flex-fields options from kwargs and request query params.

### Signature {#--init---signature}

`__init__(args, kwargs)`

#### Parameters {#--init---parameters}

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| <span id="--init---param-args">args</span> |  | no |  |  |
| <span id="--init---param-kwargs">kwargs</span> |  | no |  |  |

### Source {#--init---source}

`server/vueda/user/serializers.py:129`

## `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/user/serializers.py:185`

## `to_internal_value` {#to_internal_value}

``?e=`` (expand) names relations whose payload is a nested object rather than a flat
PK, so each expanded relation is swapped for its nested serializer here, before
deserialization, to accept that shape. See the nested-writable-inlines guide for the
query-param contract; this half of flex-field handling is independent of sparse-fieldset
narrowing and stays on the write path.

``?f=``/``?om=`` are not applied here. They narrow the representation only, in
``to_representation`` (via ``ensure_flex_fields_applied``), so a required field they
exclude still fails validation instead of silently losing its validator. Deserialization
must not call ``ensure_flex_fields_applied`` for this reason: that helper runs the full
``apply_flex_fields``, sparse-fieldset removal included, which is exactly what would
drop the validator.

### Signature {#to_internal_value-signature}

`to_internal_value(self, data)`

#### Parameters {#to_internal_value-parameters}

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

### Source {#to_internal_value-source}

`server/vueda/user/serializers.py:156`

## `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/user/serializers.py:199`

## `validate_password` {#validate_password}

### Signature {#validate_password-signature}

`validate_password(self, value)`

#### Parameters {#validate_password-parameters}

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

### Source {#validate_password-source}

`server/vueda/user/serializers.py:172`

## `validate_password_confirm` {#validate_password_confirm}

### Signature {#validate_password_confirm-signature}

`validate_password_confirm(self, value)`

#### Parameters {#validate_password_confirm-parameters}

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

### Source {#validate_password_confirm-source}

`server/vueda/user/serializers.py:179`

## `TEMPORARY_PASSWORD` {#TEMPORARY_PASSWORD}

## `password_confirm` {#password_confirm}

## `send_welcome_email_on_create` {#send_welcome_email_on_create}

## Source

`server/vueda/user/serializers.py:118`
