Commit 47acec0f by Anton Chaporgin

Made exception message more verbose

This exception helps you to upgrade from 2 -> 3 and since a lot of fields may be in 2 using serializers.Field as parent class, this message should contain at least name of upgraded field to help user to grep and fix the codebase faster.
parent a1727058
...@@ -417,10 +417,11 @@ class Field(object): ...@@ -417,10 +417,11 @@ class Field(object):
Transform the *outgoing* native value into primitive data. Transform the *outgoing* native value into primitive data.
""" """
raise NotImplementedError( raise NotImplementedError(
'{cls}.to_representation() must be implemented.\n' '{cls}.to_representation() must be implemented for field {field_name}.\n'
'If you are upgrading from REST framework version 2 ' 'If you are upgrading from REST framework version 2 '
'you might want `ReadOnlyField`.'.format( 'you might want `ReadOnlyField`.'.format(
cls=self.__class__.__name__ cls=self.__class__.__name__,
field_name=self.field_name,
) )
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment