mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 19:43:59 +03:00
Merge pull request #1280 from tomchristie/fix-1205
Refine model manager behavior so as not to use the behavior in incorrect...
This commit is contained in:
commit
462c5e3d0d
|
@ -43,6 +43,7 @@ You can determine your currently installed version using `pip freeze`:
|
|||
### Master
|
||||
|
||||
* JSON renderer now deals with objects that implement a dict-like interface.
|
||||
* Bugfix: Refine behavior that calls model manager `all()` across nested serializer relationships, preventing erronous behavior with some non-ORM objects, and preventing unneccessary queryset re-evaluations.
|
||||
|
||||
### 2.3.10
|
||||
|
||||
|
|
|
@ -412,7 +412,13 @@ class BaseSerializer(WritableField):
|
|||
|
||||
# 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 = 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 value:
|
||||
|
|
Loading…
Reference in New Issue
Block a user