Skip to content

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 ​

Source ​

server/vueda/user/serializers.py:133

__init__ ​

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

Signature ​

__init__(args, kwargs)

Parameters ​

NameTypeRequiredDefaultDescription
argsno
kwargsno

Source ​

server/vueda/user/serializers.py:129

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(self, validated_data)

Parameters ​

NameTypeRequiredDefaultDescription
selfyes
validated_datayes

Source ​

server/vueda/user/serializers.py:185

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(self, data)

Parameters ​

NameTypeRequiredDefaultDescription
selfyes
datayes

Source ​

server/vueda/user/serializers.py:156

update ​

Signature ​

update(self, instance, validated_data)

Parameters ​

NameTypeRequiredDefaultDescription
selfyes
instanceyes
validated_datayes

Source ​

server/vueda/user/serializers.py:199

validate_password ​

Signature ​

validate_password(self, value)

Parameters ​

NameTypeRequiredDefaultDescription
selfyes
valueyes

Source ​

server/vueda/user/serializers.py:172

validate_password_confirm ​

Signature ​

validate_password_confirm(self, value)

Parameters ​

NameTypeRequiredDefaultDescription
selfyes
valueyes

Source ​

server/vueda/user/serializers.py:179

TEMPORARY_PASSWORD ​

password_confirm ​

send_welcome_email_on_create ​

Source ​

server/vueda/user/serializers.py:118