Support 'on'/'off' literals with BooleanField. Closes #4624 (#4640)

This commit is contained in:
Tom Christie 2016-11-01 11:11:34 +00:00 committed by GitHub
parent 7038571157
commit 276ed80fd3

View File

@ -644,8 +644,20 @@ class BooleanField(Field):
}
default_empty_html = False
initial = False
TRUE_VALUES = {'t', 'T', 'true', 'True', 'TRUE', '1', 1, True}
FALSE_VALUES = {'f', 'F', 'false', 'False', 'FALSE', '0', 0, 0.0, False}
TRUE_VALUES = {
't', 'T',
'true', 'True', 'TRUE',
'on', 'On', 'ON',
'1', 1,
True
}
FALSE_VALUES = {
'f', 'F',
'false', 'False', 'FALSE',
'off', 'Off', 'OFF',
'0', 0, 0.0,
False
}
def __init__(self, **kwargs):
assert 'allow_null' not in kwargs, '`allow_null` is not a valid option. Use `NullBooleanField` instead.'