Skip to content

Commit 9fb1b39

Browse files
user in example should have been instance. Closees #2191.
1 parent b7b0fd3 commit 9fb1b39

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/api-guide/serializers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ Here's an example for an `update()` method on our previous `UserSerializer` clas
326326
# would need to be handled.
327327
profile = instance.profile
328328

329-
user.username = validated_data.get('username', instance.username)
330-
user.email = validated_data.get('email', instance.email)
331-
user.save()
329+
instance.username = validated_data.get('username', instance.username)
330+
instance.email = validated_data.get('email', instance.email)
331+
instance.save()
332332

333333
profile.is_premium_member = profile_data.get(
334334
'is_premium_member',
@@ -340,7 +340,7 @@ Here's an example for an `update()` method on our previous `UserSerializer` clas
340340
)
341341
profile.save()
342342

343-
return user
343+
return instance
344344

345345
Because the behavior of nested creates and updates can be ambiguous, and may require complex dependancies between related models, REST framework 3 requires you to always write these methods explicitly. The default `ModelSerializer` `.create()` and `.update()` methods do not include support for writable nested representations.
346346

0 commit comments

Comments
 (0)