aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/serializers.py
diff options
context:
space:
mode:
authorJamie Matthews2012-11-20 09:41:36 +0000
committerJamie Matthews2012-11-20 09:41:36 +0000
commit68c397371c647e88270b8c9e9a6f5f610bbd3a2b (patch)
tree2d9de201c2e6ca25e99e7a029fe5dc620b7db42f /rest_framework/serializers.py
parenta44a94dd6ea2d9497264e267a0354cb684d398f6 (diff)
downloaddjango-rest-framework-68c397371c647e88270b8c9e9a6f5f610bbd3a2b.tar.bz2
Fix related serializers with source argument that resolves to a callable
Diffstat (limited to 'rest_framework/serializers.py')
-rw-r--r--rest_framework/serializers.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index 397866a7..2e7e2cf5 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -277,6 +277,9 @@ class BaseSerializer(Field):
"""
obj = getattr(obj, self.source or field_name)
+ if is_simple_callable(obj):
+ obj = obj()
+
# If the object has an "all" method, assume it's a relationship
if is_simple_callable(getattr(obj, 'all', None)):
return [self.to_native(item) for item in obj.all()]