1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | def check_test(v):
return not (
v is False
or v is None
or v == ''
or v == '0'
)
class CheckBoxInput(forms.CheckboxInput):
def __init__(self, attrs=None, check_test=None):
if check_test is None:
check_test = check_test
return super(CheckBoxInput, self).__init__(attrs, check_test)
class BooleanField(forms.BooleanField):
'''
BooleanField that treats '0' as unchecked.
'''
widget = CheckBoxInput
|
More like this
- RequiredNullBooleanField by wwu.housing 4 years, 1 month ago
- Serializing booleans correctly when doing dumpdata from a MySQL database using Django 0.96 by chrj 4 years, 9 months ago
- Choices class by dc 4 years, 6 months ago
- Settings file pre by beresovskiy 1 year, 1 month ago
- AgreementField by chrisrbennett 4 years, 11 months ago
Comments