Skip to content

Commit c91212b

Browse files
committed
refactor: changed BigIntegerField.to_representation simplified + calling super
1 parent f6b53d8 commit c91212b

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

rest_framework/fields.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -937,18 +937,10 @@ def __init__(self, coerce_to_string=None, **kwargs):
937937
self.coerce_to_string = coerce_to_string
938938

939939
def to_representation(self, value):
940-
coerce_to_string = getattr(self, 'coerce_to_string', api_settings.COERCE_BIGINT_TO_STRING)
940+
if getattr(self, 'coerce_to_string', api_settings.COERCE_BIGINT_TO_STRING):
941+
return '' if value is None else str(value)
941942

942-
if value is None:
943-
if coerce_to_string:
944-
return ''
945-
else:
946-
return None
947-
948-
if coerce_to_string:
949-
return str(value)
950-
else:
951-
return int(value)
943+
return super().to_representation(value)
952944

953945

954946
class FloatField(Field):

0 commit comments

Comments
 (0)