From 4a54d9f4740a2e813481ade1d5a37fa507e64ae6 Mon Sep 17 00:00:00 2001 From: htmis Date: Wed, 29 Mar 2017 20:21:18 -0400 Subject: [PATCH] Update Boolean field to more closely match python library Python Reference: distutils.util.strtobool(val) Convert a string representation of truth to true (1) or false (0). True values are y, yes, t, true, on and 1; false values are n, no, f, false, off and 0. Raises ValueError if val is anything else. --- rest_framework/fields.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5a881c772a..c81dba4d9b 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -649,6 +649,7 @@ class BooleanField(Field): initial = False TRUE_VALUES = { 't', 'T', + 'y', 'Y', 'yes', 'YES', 'true', 'True', 'TRUE', 'on', 'On', 'ON', '1', 1, @@ -656,6 +657,7 @@ class BooleanField(Field): } FALSE_VALUES = { 'f', 'F', + 'n', 'N', 'no', 'NO', 'false', 'False', 'FALSE', 'off', 'Off', 'OFF', '0', 0, 0.0,