diff options
| author | Tom Christie | 2013-12-10 00:54:11 -0800 |
|---|---|---|
| committer | Tom Christie | 2013-12-10 00:54:11 -0800 |
| commit | 462c5e3d0defaceaf4b5b946d4a9f761a56b701a (patch) | |
| tree | 7e832b33e2fec9fb92fee1323b869280227d0623 /rest_framework | |
| parent | 785a42cd5aee9e96f9b780ff144fa13c16189748 (diff) | |
| parent | c09ad1bedc8559b2e6eadf0e5b8f3732af2d9d29 (diff) | |
| download | django-rest-framework-462c5e3d0defaceaf4b5b946d4a9f761a56b701a.tar.bz2 | |
Merge pull request #1280 from tomchristie/fix-1205
Refine model manager behavior so as not to use the behavior in incorrect...
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/serializers.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 44e4b04b..0d35fb32 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -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: |
