mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-03 19:00:17 +03:00
Documentation changes for partial serializer updates
This commit is contained in:
parent
c3644234cd
commit
3b43d41e91
|
@ -77,6 +77,10 @@ When deserializing data, we can either create a new instance, or update an exist
|
||||||
serializer = CommentSerializer(data=data) # Create new instance
|
serializer = CommentSerializer(data=data) # Create new instance
|
||||||
serializer = CommentSerializer(comment, data=data) # Update `instance`
|
serializer = CommentSerializer(comment, data=data) # Update `instance`
|
||||||
|
|
||||||
|
By default, serializers must be passed values for all required fields or they will throw validation errors. You can use the `partial` argument in order to allow partial updates.
|
||||||
|
|
||||||
|
serializer = CommentSerializer(comment, data={'content': u'foo bar'}, partial=True) # Update `instance` with partial data
|
||||||
|
|
||||||
## Validation
|
## Validation
|
||||||
|
|
||||||
When deserializing data, you always need to call `is_valid()` before attempting to access the deserialized object. If any validation errors occur, the `.errors` and `.non_field_errors` properties will contain the resulting error messages.
|
When deserializing data, you always need to call `is_valid()` before attempting to access the deserialized object. If any validation errors occur, the `.errors` and `.non_field_errors` properties will contain the resulting error messages.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user