From b4f3379c7002f0c80a26605fdd9c69d7cef2f16f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 15 Oct 2014 15:13:28 +0100 Subject: Support fields that reference a simple callable --- rest_framework/fields.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rest_framework/fields.py') diff --git a/rest_framework/fields.py b/rest_framework/fields.py index b881ad13..24dfaaf5 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -66,6 +66,8 @@ def get_attribute(instance, attrs): return instance[attr] except (KeyError, TypeError, AttributeError): raise exc + if is_simple_callable(instance): + return instance() return instance @@ -1025,8 +1027,6 @@ class ReadOnlyField(Field): super(ReadOnlyField, self).__init__(**kwargs) def to_representation(self, value): - if is_simple_callable(value): - return value() return value -- cgit v1.2.3