aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2014-12-15 09:29:54 +0000
committerTom Christie2014-12-15 09:29:54 +0000
commit488b13e7b8591f667a01c01f3f0aa09749627831 (patch)
tree3cefa56f6ea9335e77c2f7b64901db82da687bed /rest_framework
parenta72f812d80a4000e86a5ad96001f3fbf43fe310a (diff)
downloaddjango-rest-framework-488b13e7b8591f667a01c01f3f0aa09749627831.tar.bz2
Better messaging for 'Field.to_representation'. Closes #2271.
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/fields.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index 205efd2f..21a1effd 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -382,13 +382,23 @@ class Field(object):
"""
Transform the *incoming* primitive data into a native value.
"""
- raise NotImplementedError('to_internal_value() must be implemented.')
+ raise NotImplementedError(
+ '{cls}.to_internal_value() must be implemented.'.format(
+ cls=self.__class__.__name__
+ )
+ )
def to_representation(self, value):
"""
Transform the *outgoing* native value into primitive data.
"""
- raise NotImplementedError('to_representation() must be implemented.')
+ raise NotImplementedError(
+ '{cls}.to_representation() must be implemented.\n'
+ 'If you are upgrading from REST framework version 2 '
+ 'you might want `ReadOnlyField`.'.format(
+ cls=self.__class__.__name__
+ )
+ )
def fail(self, key, **kwargs):
"""