Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#10750 closed (fixed)

BaseInlineFormSet does not respect commit=False in save for new objects after r10190

Reported by: Koen Biermans <koen.biermans@…> Owned by: jkocherhans
Component: Forms Version: master
Severity: Keywords: formsets
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The save_new method on BaseInlineFormSet does not respect the commit bit passed to it (it saves the object even if commit=False). This method was added in r10190.

This means that if there are required fields that the forms on the inlineformset do not contain, you get an error, even if you use commit=False to add the required information to the new objects yourself.

Possible fix: do not do obj.save() if commit is False (line 549 in django/forms/models.py).

Attachments (2)

10750_baseinlineformset_savenew.diff (2.2 KB) - added by Koen Biermans <koen.biermans@…> 7 years ago.
fix and test for baseinlineformset save not respecting commit=False
10750_baseinlineformset_savenew.2.diff (2.2 KB) - added by Koen Biermans <koen.biermans@…> 7 years ago.
new try, replace messed up diff

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by Koen Biermans <koen.biermans@…>

fix and test for baseinlineformset save not respecting commit=False

Changed 7 years ago by Koen Biermans <koen.biermans@…>

new try, replace messed up diff

comment:1 Changed 7 years ago by jkocherhans

Has patch: set
Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to jkocherhans
Patch needs improvement: unset
Status: newassigned
Triage Stage: UnreviewedAccepted

Thanks for adding a test case. I'll put this on my review list for 1.1.

comment:2 Changed 7 years ago by Thejaswi Puthraya

Component: UncategorizedForms

comment:3 Changed 7 years ago by Jacob

milestone: 1.1

comment:4 Changed 7 years ago by Jacob

Resolution: fixed
Status: assignedclosed

(In [10706]) Fixed #10750: respect comment=False in inline formsets. Thanks, Koen Biermans.

comment:5 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

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