diff options
| author | Stanislas Guerra <stanislas.guerra@gmail.com> | 2015-02-24 10:54:05 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-02-24 11:49:27 -0500 |
| commit | a3fca05b05551fdd7089e7be49d48c454ea50a84 (patch) | |
| tree | 64109dd3db1ec30758c56eebff3d6c3f09a87efb /django/forms/models.py | |
| parent | 450b42eafe46bd3df916f94c7274e0d6ae8ca029 (diff) | |
[1.8.x] Fixed #24395 -- Ensured inline ModelsForms have an updated related instance.
Backport of 4c2f546b55c029334d22e69bb29db97f9356faa3 from master
Diffstat (limited to 'django/forms/models.py')
| -rw-r--r-- | django/forms/models.py | 4 |
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) |
