Opened 5 years ago

Closed 3 years ago

Last modified 3 years ago

#16869 closed Bug (fixed)

BaseGenericInlineFormSet does not use form's save() method

Reported by: Matt Austin Owned by: pyriku
Component: contrib.contenttypes Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


Changeset [12268] introduced the save_new() method on BaseGenericInlineFormSet - however this uses creates a new object based on self.model and thehn uses save_instance(), bypassing any custom code on the form's save() method.

Would the following not provide the same functionality and honor the form's save() method?

    def save_new(self, form, commit=True):
        setattr(form.instance, self.ct_field.get_attname(),
        setattr(form.instance, self.ct_fk_field.get_attname(),

Attachments (1)

save_new_using_form_save.patch (1.1 KB) - added by pyriku 5 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by pyriku

Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to pyriku
Patch needs improvement: unset

Changed 5 years ago by pyriku

comment:2 Changed 5 years ago by pyriku

Has patch: set

Attached the patch as described.

comment:3 Changed 5 years ago by pyriku

Triage Stage: UnreviewedAccepted

comment:4 Changed 4 years ago by Ramiro Morales

Needs documentation: set
Needs tests: set

comment:5 Changed 3 years ago by polmuz

Needs documentation: unset
Needs tests: unset

I added a test for the patch provided by pyriku and created a pull request with it.

comment:6 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In b11564fd36587b1077bf7d77b62b7879cc08c382:

Fixed #16869 -- BaseGenericInlineFormSet.save_new should use form's save() method

Thanks mattaustin for the report and Pablo Recio (pyriku) for the patch.

comment:7 Changed 3 years ago by Matt Austin

Thanks for the patch/commit. Any chance of this being cherry-picked to Django 1.6, or are we too late?

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