mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
parent
22a389d0ba
commit
e80d3d1bdf
|
@ -91,9 +91,10 @@ To serialize a queryset instead of an object instance, you should pass the `many
|
|||
|
||||
## 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` property will contain a dictionary representing the resulting error messages.
|
||||
Each key in the dictionary will be the field name, and the values will be lists of strings of any error messages corresponding to that field. The `non_field_errors` key may also be present, and will list any general validation errors.
|
||||
|
||||
When deserialising a list of items, errors will be returned as a list of tuples. The first item in an error tuple will be the index of the item with the error in the original data; The second item in the tuple will be a dict with the individual errors for that item.
|
||||
When deserializing a list of items, errors will be returned as a list of dictionaries representing each of the deserialized items.
|
||||
|
||||
### Field-level validation
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user