mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-30 05:24:00 +03:00
Fix serializer restore_object example for partial updates
This commit is contained in:
parent
ef0caf64d3
commit
034c4ce408
|
@ -42,9 +42,9 @@ Declaring a serializer looks very similar to declaring a form:
|
||||||
data will simply return a dictionary of items.
|
data will simply return a dictionary of items.
|
||||||
"""
|
"""
|
||||||
if instance is not None:
|
if instance is not None:
|
||||||
instance.title = attrs['title']
|
instance.title = attrs.get('title', instance.title)
|
||||||
instance.content = attrs['content']
|
instance.content = attrs.get('content', instance.content)
|
||||||
instance.created = attrs['created']
|
instance.created = attrs.get('created', instance.created)
|
||||||
return instance
|
return instance
|
||||||
return Comment(**attrs)
|
return Comment(**attrs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user