Fixing failing test with coercing strs to ints

This commit is contained in:
Kirill Gagarski 2019-12-14 01:16:01 +03:00
parent 00b7bb8110
commit f4376fb683

View File

@ -1468,7 +1468,7 @@ class ChoiceField(Field):
def to_representation(self, value): def to_representation(self, value):
# Preserving old untyped behavior # Preserving old untyped behavior
if not self.underlying_field: if not self.underlying_field:
return value return self.choice_reprs_to_values.get(str(value), value)
return self.underlying_field.to_representation(value) return self.underlying_field.to_representation(value)
def iter_options(self): def iter_options(self):
@ -1533,7 +1533,9 @@ class MultipleChoiceField(ChoiceField):
def to_representation(self, value): def to_representation(self, value):
return { return {
self.underlying_field.to_representation(item) if self.underlying_field else value for item in value self.underlying_field.to_representation(item)
if self.underlying_field
else self.choice_reprs_to_values.get(str(item), item) for item in value
} }