summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 48fe2f4ac2..b8345d8856 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -891,6 +891,10 @@ class BaseInlineFormSet(BaseModelFormSet):
return cls.fk.rel.get_accessor_name(model=cls.model).replace('+', '')
def save_new(self, form, commit=True):
+ # Ensure the latest copy of the related instance is present on each
+ # 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)