Ticket #15124: 15124ticket.v3.diff

File 15124ticket.v3.diff, 3.6 KB (added by chomik, 3 years ago)

corrects 15124.v2 FlatPage BooleanFields to have default value

  • django/contrib/flatpages/models.py

    diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
    index 85873ac..8563418 100644
    a b class FlatPage(models.Model): 
    77    url = models.CharField(_('URL'), max_length=100, db_index=True)
    88    title = models.CharField(_('title'), max_length=200)
    99    content = models.TextField(_('content'), blank=True)
    10     enable_comments = models.BooleanField(_('enable comments'))
     10    enable_comments = models.BooleanField(_('enable comments'), default=False)
    1111    template_name = models.CharField(_('template name'), max_length=70, blank=True,
    1212        help_text=_("Example: 'flatpages/contact_page.html'. If this isn't provided, the system will use 'flatpages/default.html'."))
    13     registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page."))
     13    registration_required = models.BooleanField(_('registration required'),
     14        help_text=_("If this is checked, only logged-in users will be able to view the page."),
     15        default=False)
    1416    sites = models.ManyToManyField(Site)
    1517
    1618    class Meta:
  • django/db/models/fields/__init__.py

    diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
    index 42b727d..6583328 100644
    a b class BooleanField(Field): 
    553553    description = _("Boolean (Either True or False)")
    554554    def __init__(self, *args, **kwargs):
    555555        kwargs['blank'] = True
    556         if 'default' not in kwargs and not kwargs.get('null'):
    557             kwargs['default'] = False
    558556        Field.__init__(self, *args, **kwargs)
    559557
    560558    def get_internal_type(self):
  • docs/releases/index.txt

    diff --git a/docs/releases/index.txt b/docs/releases/index.txt
    index f7b04d4..72b6d8b 100644
    a b notes. 
    8181.. toctree::
    8282   :maxdepth: 1
    8383
     84   1.4-beta-1
    8485   1.4-alpha-1
    8586   1.3-beta-1
    8687   1.3-alpha-1
  • tests/regressiontests/model_fields/tests.py

    diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
    index 8fe67fb..3774990 100644
    a b class BooleanFieldTests(unittest.TestCase): 
    211211            select={'string_length': 'LENGTH(string)'})[0]
    212212        self.assertFalse(isinstance(b5.pk, bool))
    213213
     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
    214221class ChoicesTests(test.TestCase):
    215222    def test_choices_and_field_display(self):
    216223        """
  • tests/regressiontests/model_inheritance_regress/tests.py

    diff --git a/tests/regressiontests/model_inheritance_regress/tests.py b/tests/regressiontests/model_inheritance_regress/tests.py
    index 8e2c56b..752386a 100644
    a b class ModelInheritanceTest(TestCase): 
    180180        """
    181181        Regression test for #6755
    182182        """
    183         r = Restaurant(serves_pizza=False)
     183        r = Restaurant(serves_pizza=False, serves_hot_dogs=False)
    184184        r.save()
    185185        self.assertEqual(r.id, r.place_ptr_id)
    186186        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)
    188188        r.save()
    189189        self.assertEqual(r.id, orig_id)
    190190        self.assertEqual(r.id, r.place_ptr_id)
Back to Top