Opened 6 years ago

Closed 6 years ago

Last modified 4 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@…> 6 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@…> 6 years ago.
new try, replace messed up diff

Download all attachments as: .zip

Change History (7)

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

fix and test for baseinlineformset save not respecting commit=False

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

new try, replace messed up diff

comment:1 Changed 6 years ago by jkocherhans

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jkocherhans
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

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

comment:2 Changed 6 years ago by thejaswi_puthraya

  • Component changed from Uncategorized to Forms

comment:3 Changed 6 years ago by jacob

  • milestone set to 1.1

comment:4 Changed 6 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:5 Changed 4 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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