summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorAlexander Kavanaugh <alex@kavdev.io>2017-05-01 16:58:28 -0700
committerTim Graham <timograham@gmail.com>2017-05-03 07:45:51 -0400
commit362fba87c9bb4f88542ba82ce4a732fed2634be7 (patch)
tree175f701281df706f939d331754dc738da37982e3 /django/forms
parent9b2d47bcded8320114193e9b2a200119a19974a6 (diff)
Fixed #28159 -- Fixed BaseInlineFormSet._construct_form() crash when using save_as_new.
Regression in 4a246a02bdcbc13b15480c014f51cb0682af7c1e.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index adc31081b7..b58d8e5b99 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -884,12 +884,17 @@ class BaseInlineFormSet(BaseModelFormSet):
def _construct_form(self, i, **kwargs):
form = super()._construct_form(i, **kwargs)
if self.save_as_new:
+ mutable = getattr(form.data, '_mutable', None)
+ # Allow modifying an immutable QueryDict.
+ if mutable is not None:
+ form.data._mutable = True
# Remove the primary key from the form's data, we are only
# creating new instances
form.data[form.add_prefix(self._pk_field.name)] = None
-
# Remove the foreign key from the form's data
form.data[form.add_prefix(self.fk.name)] = None
+ if mutable is not None:
+ form.data._mutable = mutable
# Set the fk value here so that the form can do its validation.
fk_value = self.instance.pk