From 765b0904aaaa1491475bc16ddd377cd49650c5f8 Mon Sep 17 00:00:00 2001 From: MoeSalah1999 <161456250+MoeSalah1999@users.noreply.github.com> Date: Sat, 24 Jan 2026 19:43:43 +0300 Subject: [PATCH] Update serializers.py Re-introduced old example mentioned --- rest_framework/serializers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index e1708dea6..5f9e957d7 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -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