diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
index 42ec155..18ce335 100644
a
|
b
|
class FlatPage(models.Model):
|
9 | 9 | url = models.CharField(_('URL'), max_length=100, db_index=True) |
10 | 10 | title = models.CharField(_('title'), max_length=200) |
11 | 11 | content = models.TextField(_('content'), blank=True) |
12 | | enable_comments = models.BooleanField(_('enable comments')) |
| 12 | enable_comments = models.BooleanField(_('enable comments'), default=False) |
13 | 13 | template_name = models.CharField(_('template name'), max_length=70, blank=True, |
14 | 14 | help_text=_("Example: 'flatpages/contact_page.html'. If this isn't provided, the system will use 'flatpages/default.html'.")) |
15 | | registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page.")) |
| 15 | registration_required = models.BooleanField(_('registration required'), |
| 16 | help_text=_("If this is checked, only logged-in users will be able to view the page."), |
| 17 | default=False) |
16 | 18 | sites = models.ManyToManyField(Site) |
17 | 19 | |
18 | 20 | class Meta: |
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 9db76a6..99bf2fe 100644
a
|
b
|
class BooleanField(Field):
|
568 | 568 | |
569 | 569 | def __init__(self, *args, **kwargs): |
570 | 570 | kwargs['blank'] = True |
571 | | if 'default' not in kwargs and not kwargs.get('null'): |
572 | | kwargs['default'] = False |
573 | 571 | Field.__init__(self, *args, **kwargs) |
574 | 572 | |
575 | 573 | def get_internal_type(self): |
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 23dcf4b..6d411d3 100644
a
|
b
|
The admin represents this as a checkbox.
|
351 | 351 | If you need to accept :attr:`~Field.null` values then use |
352 | 352 | :class:`NullBooleanField` instead. |
353 | 353 | |
| 354 | .. versionchanged:: 1.5 |
| 355 | In previous versions of Django ``BooleanFields`` would have an implicit |
| 356 | default value of ``False``. Now it defaults to ``None`` if there is |
| 357 | no default specified. |
| 358 | |
354 | 359 | ``CharField`` |
355 | 360 | ------------- |
356 | 361 | |
diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
index 33f5003..7062240 100644
a
|
b
|
our own copy of ``simplejson``. You can safely change any use of
|
160 | 160 | |
161 | 161 | The :func:`~django.utils.itercompat.product` function has been deprecated. Use |
162 | 162 | the built-in :func:`itertools.product` instead. |
| 163 | |
| 164 | |
| 165 | ``BooleanField`` set to None when default value not specified |
| 166 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 167 | |
| 168 | In previous versions of Django, a model's ``BooleanField`` would get ``False`` |
| 169 | value when no default was provided. Now ``None`` value is used. |
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index 5d3d42e..a270235 100644
a
|
b
|
class BooleanFieldTests(unittest.TestCase):
|
211 | 211 | select={'string_col': 'string'})[0] |
212 | 212 | self.assertFalse(isinstance(b5.pk, bool)) |
213 | 213 | |
| 214 | def test_null_default(self): |
| 215 | # http://code.djangoproject.com/ticket/15124 |
| 216 | from django.db import IntegrityError |
| 217 | b = BooleanModel() |
| 218 | self.assertEqual(b.bfield, None) |
| 219 | self.assertRaises(IntegrityError, b.save) |
| 220 | |
214 | 221 | class ChoicesTests(test.TestCase): |
215 | 222 | def test_choices_and_field_display(self): |
216 | 223 | """ |
diff --git a/tests/regressiontests/model_inheritance_regress/tests.py b/tests/regressiontests/model_inheritance_regress/tests.py
index 6855d70..80ffec9 100644
a
|
b
|
class ModelInheritanceTest(TestCase):
|
180 | 180 | """ |
181 | 181 | Regression test for #6755 |
182 | 182 | """ |
183 | | r = Restaurant(serves_pizza=False) |
| 183 | r = Restaurant(serves_pizza=False, serves_hot_dogs=False) |
184 | 184 | r.save() |
185 | 185 | self.assertEqual(r.id, r.place_ptr_id) |
186 | 186 | orig_id = r.id |
187 | | r = Restaurant(place_ptr_id=orig_id, serves_pizza=True) |
| 187 | r = Restaurant(place_ptr_id=orig_id, serves_pizza=True, serves_hot_dogs=False) |
188 | 188 | r.save() |
189 | 189 | self.assertEqual(r.id, orig_id) |
190 | 190 | self.assertEqual(r.id, r.place_ptr_id) |