Skip to content

Commit

Permalink
user in example should have been instance. Closees #2191.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Dec 5, 2014
1 parent b7b0fd3 commit 9fb1b39
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/api-guide/serializers.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ Here's an example for an `update()` method on our previous `UserSerializer` clas
# would need to be handled.
profile = instance.profile

user.username = validated_data.get('username', instance.username)
user.email = validated_data.get('email', instance.email)
user.save()
instance.username = validated_data.get('username', instance.username)
instance.email = validated_data.get('email', instance.email)
instance.save()

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

return user
return instance

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.

Expand Down

1 comment on commit 9fb1b39

@houkk
Copy link

@houkk houkk commented on 9fb1b39 Mar 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one to many field ,how to override '.update()'

Please sign in to comment.