Skip to content

Commit

Permalink
Fix NotImplementedError for Field.to_internal_value and Field.to_repr…
Browse files Browse the repository at this point in the history
…esentation (encode#6996)
  • Loading branch information
JEphron authored and Pierre Chiquet committed Mar 24, 2020
1 parent 2e764d1 commit cf5d59d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,11 @@ def to_internal_value(self, data):
Transform the *incoming* primitive data into a native value.
"""
raise NotImplementedError(
'{cls}.to_internal_value() must be implemented.'.format(
cls=self.__class__.__name__
'{cls}.to_internal_value() must be implemented for field '
'{field_name}. If you do not need to support write operations '
'you probably want to subclass `ReadOnlyField` instead.'.format(
cls=self.__class__.__name__,
field_name=self.field_name,
)
)

Expand All @@ -615,9 +618,7 @@ def to_representation(self, value):
Transform the *outgoing* native value into primitive data.
"""
raise NotImplementedError(
'{cls}.to_representation() must be implemented for field '
'{field_name}. If you do not need to support write operations '
'you probably want to subclass `ReadOnlyField` instead.'.format(
'{cls}.to_representation() must be implemented for field {field_name}.'.format(
cls=self.__class__.__name__,
field_name=self.field_name,
)
Expand Down

0 comments on commit cf5d59d

Please sign in to comment.