Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class ChoiceField(Field):
...
def to_representation(self, value):
if data == '' and self.allow_blank:
return ''
try:
return self.choice_strings_to_values[six.text_type(value)]
except KeyError:
return value
class MultipleChoiceField(ChoiceField):
...
def to_representation(self, value):
return set([
self.choice_strings_to_values[six.text_type(item)]
if six.text_type(value) in self.choice_strings_to_values
else item
for item in value
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment