Skip to content

Commit

Permalink
Added a root_obj field to the NestedInline class
Browse files Browse the repository at this point in the history
  • Loading branch information
ralkan committed Oct 13, 2017
1 parent d6fbc09 commit 63367bb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nested_inline/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 = []

Expand All @@ -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
Expand Down

0 comments on commit 63367bb

Please sign in to comment.