Fixes #2319: Extend ChoiceField to properly handle true/false choice keys

This commit is contained in:
Jeremy Stretch 2018-08-07 13:48:29 -04:00
parent f4485dc72a
commit c51c20a301

View File

@ -74,6 +74,12 @@ class ChoiceField(Field):
return {'value': obj, 'label': self._choices[obj]} return {'value': obj, 'label': self._choices[obj]}
def to_internal_value(self, data): def to_internal_value(self, data):
# Hotwiring boolean values
if hasattr(data, 'lower'):
if data.lower() == 'true':
return True
if data.lower() == 'false':
return False
return data return data