diff --git a/nested_inline/admin.py b/nested_inline/admin.py index 9ec6290..7f1a2d3 100644 --- a/nested_inline/admin.py +++ b/nested_inline/admin.py @@ -321,6 +321,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None): inline_admin_formsets = [] for inline, formset in zip(inline_instances, formsets): + inline.root_obj = obj fieldsets = list(inline.get_fieldsets(request, obj)) readonly = list(inline.get_readonly_fields(request, obj)) prepopulated = dict(inline.get_prepopulated_fields(request, obj)) @@ -348,6 +349,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None): class NestedInline(InlineModelAdmin): + root_obj = None inlines = [] new_objects = [] @@ -365,6 +367,7 @@ def get_inline_instances(self, request, obj=None): inline_instances = [] for inline_class in self.inlines: inline = inline_class(self.model, self.admin_site) + inline.root_obj = self.root_obj if request: if not (inline.has_add_permission(request) or inline.has_change_permission(request, obj) or