Skip to content

Commit 276ed80

Browse files
authored
Support 'on'/'off' literals with BooleanField. Closes #4624 (#4640)
1 parent 7038571 commit 276ed80

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

rest_framework/fields.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,20 @@ class BooleanField(Field):
644644
}
645645
default_empty_html = False
646646
initial = False
647-
TRUE_VALUES = {'t', 'T', 'true', 'True', 'TRUE', '1', 1, True}
648-
FALSE_VALUES = {'f', 'F', 'false', 'False', 'FALSE', '0', 0, 0.0, False}
647+
TRUE_VALUES = {
648+
't', 'T',
649+
'true', 'True', 'TRUE',
650+
'on', 'On', 'ON',
651+
'1', 1,
652+
True
653+
}
654+
FALSE_VALUES = {
655+
'f', 'F',
656+
'false', 'False', 'FALSE',
657+
'off', 'Off', 'OFF',
658+
'0', 0, 0.0,
659+
False
660+
}
649661

650662
def __init__(self, **kwargs):
651663
assert 'allow_null' not in kwargs, '`allow_null` is not a valid option. Use `NullBooleanField` instead.'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy