summaryrefslogtreecommitdiff
path: root/tests/regressiontests/model_fields
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-29 02:40:56 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-29 02:40:56 +0000
commit54f41e3507bee76b5e1556b25ddbb57c47c8b84b (patch)
tree85800e11c78680ee76ca2370bc0b9b3c977f392a /tests/regressiontests/model_fields
parenta1d2f6ef0cfd48c9999edfd8b24766257f58d2d5 (diff)
Fixed #8101 -- Allow the strings '1' and '0' as filter values for boolean
fields (the latter was causing problems). This allows these values in URLs (e.g. the admin filtering). Not an ideal solution to the problem, but will do the job for the time being. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8691 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/model_fields')
-rw-r--r--tests/regressiontests/model_fields/tests.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index 0e67c60ac9..80ff4bada6 100644
--- a/tests/regressiontests/model_fields/tests.py
+++ b/tests/regressiontests/model_fields/tests.py
@@ -45,5 +45,31 @@ datetime.time(1, 2, 3, 4)
>>> f.to_python('01:02:03.999999')
datetime.time(1, 2, 3, 999999)
+# Boolean and null boolean fields
+>>> f = BooleanField()
+>>> for val in (True, '1', 1):
+... f.get_db_prep_lookup('exact', val)
+[True]
+[True]
+[True]
+>>> for val in (False, '0', 0):
+... f.get_db_prep_lookup('exact', val)
+[False]
+[False]
+[False]
+
+>>> f = NullBooleanField()
+>>> for val in (True, '1', 1):
+... f.get_db_prep_lookup('exact', val)
+[True]
+[True]
+[True]
+>>> for val in (False, '0', 0):
+... f.get_db_prep_lookup('exact', val)
+[False]
+[False]
+[False]
+>>> f.get_db_prep_lookup('exact', None)
+[None]
"""