#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 |
Description
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(), ContentType.objects.get_for_model(self.instance).pk) setattr(form.instance, self.ct_fk_field.get_attname(), self.instance.pk) return form.save(commit=commit)
Attachments (1)
Change History (8)
comment:1 by , 13 years ago
Owner: | changed from | to
---|
by , 13 years ago
Attachment: | save_new_using_form_save.patch added |
---|
comment:2 by , 13 years ago
Has patch: | set |
---|
comment:3 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 12 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
comment:5 by , 11 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
I added a test for the patch provided by pyriku and created a pull request with it. https://github.com/django/django/pull/1599
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 11 years ago
Thanks for the patch/commit. Any chance of this being cherry-picked to Django 1.6, or are we too late?
Attached the patch as described.