user in example should have been instance. Closees #2191.

This commit is contained in:
Tom Christie 2014-12-05 13:07:31 +00:00
parent b7b0fd3e14
commit 9fb1b396db

View File

@ -326,9 +326,9 @@ Here's an example for an `update()` method on our previous `UserSerializer` clas
# would need to be handled. # would need to be handled.
profile = instance.profile profile = instance.profile
user.username = validated_data.get('username', instance.username) instance.username = validated_data.get('username', instance.username)
user.email = validated_data.get('email', instance.email) instance.email = validated_data.get('email', instance.email)
user.save() instance.save()
profile.is_premium_member = profile_data.get( profile.is_premium_member = profile_data.get(
'is_premium_member', 'is_premium_member',
@ -340,7 +340,7 @@ Here's an example for an `update()` method on our previous `UserSerializer` clas
) )
profile.save() 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. 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.