Last active
September 19, 2025 15:59
-
-
Save amatellanes/9920823 to your computer and use it in GitHub Desktop.
A Yes/No field for Django.
This file contains hidden or 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'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you can fix this by adding the arguments:
blank=True, null=True