Skip to content

Commit 3c1428f

Browse files
JEphrontomchristie
authored andcommitted
Fix NotImplementedError for Field.to_internal_value and Field.to_representation (#6996)
1 parent b8c369c commit 3c1428f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

rest_framework/fields.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,11 @@ def to_internal_value(self, data):
605605
Transform the *incoming* primitive data into a native value.
606606
"""
607607
raise NotImplementedError(
608-
'{cls}.to_internal_value() must be implemented.'.format(
609-
cls=self.__class__.__name__
608+
'{cls}.to_internal_value() must be implemented for field '
609+
'{field_name}. If you do not need to support write operations '
610+
'you probably want to subclass `ReadOnlyField` instead.'.format(
611+
cls=self.__class__.__name__,
612+
field_name=self.field_name,
610613
)
611614
)
612615

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

0 commit comments

Comments
 (0)