mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 05:20:12 +03:00
fix for keyerror with choicefield
This commit is contained in:
parent
da9daa7002
commit
864335d9b3
|
@ -1024,8 +1024,10 @@ class ChoiceField(Field):
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
if value in ('', None):
|
if value in ('', None):
|
||||||
return value
|
return value
|
||||||
return self.choice_strings_to_values[six.text_type(value)]
|
try:
|
||||||
|
return self.choice_strings_to_values[six.text_type(value)]
|
||||||
|
except KeyError:
|
||||||
|
return value
|
||||||
|
|
||||||
class MultipleChoiceField(ChoiceField):
|
class MultipleChoiceField(ChoiceField):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user