From a3fca05b05551fdd7089e7be49d48c454ea50a84 Mon Sep 17 00:00:00 2001 From: Stanislas Guerra Date: Tue, 24 Feb 2015 10:54:05 +0100 Subject: [1.8.x] Fixed #24395 -- Ensured inline ModelsForms have an updated related instance. Backport of 4c2f546b55c029334d22e69bb29db97f9356faa3 from master --- django/forms/models.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'django/forms') 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) -- cgit v1.3