Last active
February 19, 2021 09:55
-
-
Save amatellanes/9920823 to your computer and use it in GitHub Desktop.
A Yes/No field for Django.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
class Form(forms.Form): | |
field = forms.TypedChoiceField(coerce=lambda x: x =='True', | |
choices=((False, 'No'), (True, 'Yes'))) |
I think you can fix this by adding the arguments: blank=True, null=True
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if i put this field requited=False i have this error Field 'field' expected a number but got '' any idea put this field not required,
in my models put field null=True and blank=True but nothing the same error?
any idea to solve this