mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
allow serialization of blank choice if field is not required
This commit is contained in:
parent
4e03518438
commit
bc736c010a
|
@ -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)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user