mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Fixed #24395 -- Ensured inline ModelsForms have an updated related instance.
This commit is contained in:
committed by
Tim Graham
parent
8e129b42ad
commit
4c2f546b55
@@ -904,6 +904,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)
|
||||
|
||||
Reference in New Issue
Block a user