Commit 3a1c40f8 by Tom Christie

Refine model manager behavior so as not to use the behavior in incorrect cases. Closes #1205

parent 785a42cd
...@@ -412,7 +412,13 @@ class BaseSerializer(WritableField): ...@@ -412,7 +412,13 @@ class BaseSerializer(WritableField):
# Set the serializer object if it exists # Set the serializer object if it exists
obj = get_component(self.parent.object, self.source or field_name) if self.parent.object else None obj = get_component(self.parent.object, self.source or field_name) if self.parent.object else None
obj = obj.all() if is_simple_callable(getattr(obj, 'all', None)) else obj
# 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 self.source == '*':
if value: if value:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment