From 5ce8fe35661cf2cc85721d839646cd12d3ed7555 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 12 Oct 2017 17:44:32 +0100 Subject: [PATCH] Remove dont_use_model_field_default_for_empty_data flag required by Django 1.10.1 --- wagtail/wagtailadmin/tests/test_pages_views.py | 8 +++----- wagtail/wagtailcore/blocks/base.py | 5 ----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/wagtail/wagtailadmin/tests/test_pages_views.py b/wagtail/wagtailadmin/tests/test_pages_views.py index 0873af2412..0cbe6351fe 100644 --- a/wagtail/wagtailadmin/tests/test_pages_views.py +++ b/wagtail/wagtailadmin/tests/test_pages_views.py @@ -3957,11 +3957,9 @@ class TestRecentEditsPanel(TestCase, WagtailTestUtils): class TestIssue2994(TestCase, WagtailTestUtils): """ - When submitting the add/edit page form, Django 1.10.1 fails to update StreamFields - that have a default value, because it notices the lack of postdata field - with a name exactly matching the field name and wrongly assumes that the field has - been omitted from the form. To avoid this in Django 1.10.1, we need to set - dont_use_model_field_default_for_empty_data=True on the widget; in Django >=1.10.2, + In contrast to most "standard" form fields, StreamField form widgets generally won't + provide a postdata field with a name exactly matching the field name. To prevent Django + from wrongly interpreting this as the field being omitted from the form, we need to provide a custom value_omitted_from_data method. """ def setUp(self): diff --git a/wagtail/wagtailcore/blocks/base.py b/wagtail/wagtailcore/blocks/base.py index 74ff8b3254..399b576edc 100644 --- a/wagtail/wagtailcore/blocks/base.py +++ b/wagtail/wagtailcore/blocks/base.py @@ -487,11 +487,6 @@ class DeclarativeSubBlocksMetaclass(BaseBlock): class BlockWidget(forms.Widget): """Wraps a block object as a widget so that it can be incorporated into a Django form""" - # Flag used by Django 1.10.1 (only) to indicate that this widget will not necessarily submit - # a postdata item with a name that matches the field name - - # see https://github.com/django/django/pull/7068, https://github.com/wagtail/wagtail/issues/2994 - dont_use_model_field_default_for_empty_data = True - def __init__(self, block_def, attrs=None): super(BlockWidget, self).__init__(attrs=attrs) self.block_def = block_def