fix for keyerror with choicefield

This commit is contained in:
Matt Bartolome 2015-02-18 08:42:19 -08:00
parent da9daa7002
commit 864335d9b3

View File

@ -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 = {