allow serialization of blank choice if field is not required

This commit is contained in:
Michael Ching 2014-11-14 02:10:58 +00:00
parent 4e03518438
commit bc736c010a

View File

@ -929,6 +929,10 @@ class ChoiceField(Field):
super(ChoiceField, self).__init__(**kwargs)
if not self.required:
self.choices[''] = ''
self.choice_strings_to_values[''] = ''
def to_internal_value(self, data):
try:
return self.choice_strings_to_values[six.text_type(data)]