Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28159 closed Bug (fixed)

Using InlineFormset.save_as_new crashes in Django 1.11

Reported by: Alexander Kavanaugh Owned by: nobody
Component: Forms Version: 1.11
Severity: Release blocker Keywords: inlineformset, save_as_new
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

Django 1.11 marks multipart POST data as immutable: 4a246a02bdcbc13b15480c014f51cb0682af7c1e (#17235) . This causes an issue with the private save_as_new feature in InlineFormsets: the set code in the conditional block in BaseInlineFormSet._construct_form() now raises AttributeError because the data it's attempting to change is marked as immutable.

To restore previous behavior, this pull request turns off the immutability flag on the form data while the save_as_new functionality runs and turns immutability back on when the mutation code is complete.

Note that the mutable flag isn't set if there is no data, hence the hasattr code.

Change History (4)

comment:1 by Tim Graham, 7 years ago

Description: modified (diff)
Needs tests: set
Severity: NormalRelease blocker
Summary: Fix issues with InlineFormset.save_as_new in Django 1.11Using InlineFormset.save_as_new crashes in Django 1.11
Triage Stage: UnreviewedAccepted

comment:2 by Tim Graham, 7 years ago

Needs tests: unset

I added a test to the PR.

comment:3 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 362fba8:

Fixed #28159 -- Fixed BaseInlineFormSet._construct_form() crash when using save_as_new.

Regression in 4a246a02bdcbc13b15480c014f51cb0682af7c1e.

comment:4 by Tim Graham <timograham@…>, 7 years ago

In 008ba77d:

[1.11.x] Fixed #28159 -- Fixed BaseInlineFormSet._construct_form() crash when using save_as_new.

Regression in 4a246a02bdcbc13b15480c014f51cb0682af7c1e.

Backport of 362fba87c9bb4f88542ba82ce4a732fed2634be7 from master

Note: See TracTickets for help on using tickets.
Back to Top