summaryrefslogtreecommitdiff
path: root/django/forms/models.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2018-06-07 21:14:19 -0400
committerTim Graham <timograham@gmail.com>2018-06-07 21:14:19 -0400
commit236bcfea429d6b0c6b3dcd102c09d3a4c75b84d8 (patch)
treedde2302470eab4534b88226750baacc919de4cf5 /django/forms/models.py
parent6df3d3680167ec84e32fe5994c0cffc1460e4c37 (diff)
Fixed #29474 -- Simplified BaseInlineFormset.save_new().
Diffstat (limited to 'django/forms/models.py')
-rw-r--r--django/forms/models.py12
1 files changed, 1 insertions, 11 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index cf66f10c88..7f5e2544dd 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -940,17 +940,7 @@ class BaseInlineFormSet(BaseModelFormSet):
# form (it may have been saved after the formset was originally
# instantiated).
setattr(form.instance, self.fk.name, self.instance)
- # Use commit=False so we can assign the parent key afterwards, then
- # save the object.
- obj = form.save(commit=False)
- pk_value = getattr(self.instance, self.fk.remote_field.field_name)
- setattr(obj, self.fk.get_attname(), getattr(pk_value, 'pk', pk_value))
- if commit:
- obj.save()
- # form.save_m2m() can be called via the formset later on if commit=False
- if commit and hasattr(form, 'save_m2m'):
- form.save_m2m()
- return obj
+ return super().save_new(form, commit=commit)
def add_fields(self, form, index):
super().add_fields(form, index)