mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-29 21:14:01 +03:00
Don't fail when no data provided
This commit is contained in:
parent
221ecd2182
commit
83f39b3dce
|
@ -237,8 +237,13 @@ class BaseSerializer(Field):
|
||||||
if hasattr(data, '__iter__') and not isinstance(data, dict):
|
if hasattr(data, '__iter__') and not isinstance(data, dict):
|
||||||
# TODO: error data when deserializing lists
|
# TODO: error data when deserializing lists
|
||||||
return (self.from_native(item) for item in data)
|
return (self.from_native(item) for item in data)
|
||||||
|
|
||||||
self._errors = {}
|
self._errors = {}
|
||||||
|
if data is not None:
|
||||||
attrs = self.restore_fields(data)
|
attrs = self.restore_fields(data)
|
||||||
|
else:
|
||||||
|
self._errors['non_field_errors'] = 'No input provided'
|
||||||
|
|
||||||
if not self._errors:
|
if not self._errors:
|
||||||
return self.restore_object(attrs, instance=getattr(self, 'object', None))
|
return self.restore_object(attrs, instance=getattr(self, 'object', None))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user