Update serializers.py

Re-introduced old example mentioned
This commit is contained in:
MoeSalah1999 2026-01-24 19:43:43 +03:00 committed by GitHub
parent 8f0bd561e9
commit 765b0904aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -841,6 +841,14 @@ def raise_errors_on_nested_writes(method_name, serializer, validated_data):
This check is invoked internally by default `ModelSerializer.create()`
and `ModelSerializer.update()` implementations.
Eg. Suppose we have a `UserSerializer` with a nested profile. How should
we handle the case of an update, where the `profile` relationship does
not exist? Any of the following might be valid:
* Raise an application error.
* Silently ignore the nested part of the update.
* Automatically create a profile instance.
"""
ModelClass = serializer.Meta.model