diff options
| author | Jamie Matthews | 2012-11-20 09:41:36 +0000 |
|---|---|---|
| committer | Jamie Matthews | 2012-11-20 09:41:36 +0000 |
| commit | 68c397371c647e88270b8c9e9a6f5f610bbd3a2b (patch) | |
| tree | 2d9de201c2e6ca25e99e7a029fe5dc620b7db42f /rest_framework/serializers.py | |
| parent | a44a94dd6ea2d9497264e267a0354cb684d398f6 (diff) | |
| download | django-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.py | 3 |
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()] |
