Update YesNoField coercion

I am not sure if this is related to a py2/py3 change, or if it's
because django 1.11 changed the way it handles booleans; but either
way, this works.
This commit is contained in:
James Polley 2017-09-30 18:11:05 +10:00
parent 271d9e05cd
commit 9d7be5f6df

View file

@ -9,7 +9,7 @@ class YesNoField(forms.TypedChoiceField):
kwargs['required'] = True
super(YesNoField, self).__init__(
*args,
coerce=lambda x: x is True,
coerce=lambda x: x in ['True', 'Yes', True],
choices=((None, '--------'), (False, 'No'), (True, 'Yes')),
**kwargs
)