aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/serializers.py
diff options
context:
space:
mode:
authorVladislav Vlastovskiy2014-03-20 01:50:40 +0400
committerVladislav Vlastovskiy2014-03-20 01:50:40 +0400
commitc3aa10e589cb524dc3bb39a4fccee8238763d25a (patch)
tree5767a38959b46fc291a324122e6a0ced45258cc9 /rest_framework/serializers.py
parent19c03f4a60f339397b8ed03c9e6f20b3c604ffc3 (diff)
downloaddjango-rest-framework-c3aa10e589cb524dc3bb39a4fccee8238763d25a.tar.bz2
Moved get component from object after test source is star
Diffstat (limited to 'rest_framework/serializers.py')
-rw-r--r--rest_framework/serializers.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index 5c726dfc..cc0e027f 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -438,25 +438,26 @@ class BaseSerializer(WritableField):
raise ValidationError(self.error_messages['required'])
return
- # Set the serializer object if it exists
- obj = get_component(self.parent.object, self.source or field_name) if self.parent.object else None
-
- # If we have a model manager or similar object then we need
- # to iterate through each instance.
- if (self.many and
- not hasattr(obj, '__iter__') and
- is_simple_callable(getattr(obj, 'all', None))):
- obj = obj.all()
-
- if self.source == '*':
- if value:
- reverted_data = self.restore_fields(value, {})
- if not self._errors:
- into.update(reverted_data)
else:
if value in (None, ''):
into[(self.source or field_name)] = None
else:
+ # Set the serializer object if it exists
+ obj = get_component(self.parent.object, self.source or field_name) if self.parent.object else None
+
+ # If we have a model manager or similar object then we need
+ # to iterate through each instance.
+ if (self.many and
+ not hasattr(obj, '__iter__') and
+ is_simple_callable(getattr(obj, 'all', None))):
+ obj = obj.all()
+
+ if self.source == '*':
+ if value:
+ reverted_data = self.restore_fields(value, {})
+ if not self._errors:
+ into.update(reverted_data)
+
kwargs = {
'instance': obj,
'data': value,