Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a forgotten super call for admin.NestedModelAdmin.get_inline_instances and misuse #73

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions nested_inline/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Media:
js = ('admin/js/inlines-nested.js',)

def get_inline_instances(self, request, obj=None):
inline_instances = []
inline_instances = super(
NestedModelAdmin, self).get_inline_instances(request, obj)
for inline_class in self.inlines:
inline = inline_class(self.model, self.admin_site)
if request:
Expand Down Expand Up @@ -70,7 +71,7 @@ def add_nested_inline_formsets(self, request, inline, formset, depth=0):
raise Exception("Maximum nesting depth reached (5)")
for form in formset.forms:
nested_formsets = []
for nested_inline in inline.get_inline_instances(request):
for nested_inline in inline.get_inline_instances(request, form.instance):
InlineFormSet = nested_inline.get_formset(request, form.instance)
prefix = "%s-%s" % (form.prefix, InlineFormSet.get_default_prefix())

Expand All @@ -96,7 +97,7 @@ def get_media(extra_media):

for form in formset.forms:
wrapped_nested_formsets = []
for nested_inline, nested_formset in zip(inline.get_inline_instances(request), form.nested_formsets):
for nested_inline, nested_formset in zip(inline.get_inline_instances(request, form.instance), form.nested_formsets):
if form.instance.pk:
instance = form.instance
else:
Expand Down Expand Up @@ -376,7 +377,7 @@ def get_inline_instances(self, request, obj=None):
return inline_instances

def get_formsets_with_inlines(self, request, obj=None):
for inline in self.get_inline_instances(request):
for inline in self.get_inline_instances(request, obj):
yield inline.get_formset(request, obj), inline


Expand Down