0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Remove dont_use_model_field_default_for_empty_data flag required by Django 1.10.1

This commit is contained in:
Matt Westcott 2017-10-12 17:44:32 +01:00 committed by Karl Hobley
parent 6ab10b5e11
commit 5ce8fe3566
2 changed files with 3 additions and 10 deletions

View File

@ -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):

View File

@ -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