Skip to content

Instantly share code, notes, and snippets.

@mikeyakymenko
Forked from amatellanes/forms.py
Created June 13, 2016 11:46
Show Gist options
  • Save mikeyakymenko/66ae05c055e5c1f20462cb9fe831e11b to your computer and use it in GitHub Desktop.
Save mikeyakymenko/66ae05c055e5c1f20462cb9fe831e11b to your computer and use it in GitHub Desktop.
A Yes/No field for Django.
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