summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-08-04 19:54:44 -0400
committerTim Graham <timograham@gmail.com>2014-08-05 07:49:53 -0400
commitfcd42a48190d395b8daea82acfc0609549a78705 (patch)
treebd3021bde2f3b958a4846c646379891a4dc01644
parent21d0ceefb564ffd0f20115a8b5523cc5fddaf34b (diff)
Removed code that assumed BooleanField could be null.
Such a field will no longer pass model validation.
-rw-r--r--django/db/models/fields/__init__.py3
-rw-r--r--tests/model_fields/tests.py3
2 files changed, 1 insertions, 5 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 29017bed97..4509f4139c 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -997,8 +997,7 @@ class BooleanField(Field):
# Unlike most fields, BooleanField figures out include_blank from
# self.null instead of self.blank.
if self.choices:
- include_blank = (self.null or
- not (self.has_default() or 'initial' in kwargs))
+ include_blank = not (self.has_default() or 'initial' in kwargs)
defaults = {'choices': self.get_choices(include_blank=include_blank)}
else:
defaults = {'form_class': forms.BooleanField}
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index 64b848af7a..793538c791 100644
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -259,9 +259,6 @@ class BooleanFieldTests(unittest.TestCase):
formfield with the blank option (#9640, #10549).
"""
choices = [(1, 'Si'), (2, 'No')]
- f = models.BooleanField(choices=choices, default=1, null=True)
- self.assertEqual(f.formfield().choices, [('', '---------')] + choices)
-
f = models.BooleanField(choices=choices, default=1, null=False)
self.assertEqual(f.formfield().choices, choices)