Skip to content

Commit

Permalink
Fix prefix increment for polymorphic forms
Browse files Browse the repository at this point in the history
  • Loading branch information
felton committed Jan 10, 2025
1 parent be95b2e commit 3af8e52
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nested_admin/nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,6 @@ def _create_formsets(self, request, obj, change):
is_empty_form = True
InlineFormSet = inline.get_formset(request, form_obj)

prefix = '%s-%s' % (form_prefix, InlineFormSet.get_default_prefix())
prefixes[prefix] = prefixes.get(prefix, 0) + 1
if prefixes[prefix] != 1:
prefix = "%s-%s" % (prefix, prefixes[prefix])

# Check if we're dealing with a polymorphic instance, and if
# so, skip inlines for other child models
if hasattr(form_obj, 'get_real_instance'):
Expand All @@ -378,6 +373,11 @@ def _create_formsets(self, request, obj, change):
if not isinstance(form_obj, inline.parent_model):
continue

prefix = '%s-%s' % (form_prefix, InlineFormSet.get_default_prefix())
prefixes[prefix] = prefixes.get(prefix, 0) + 1
if prefixes[prefix] != 1:
prefix = "%s-%s" % (prefix, prefixes[prefix])

formset_params = {
'instance': form_obj,
'prefix': prefix,
Expand Down

0 comments on commit 3af8e52

Please sign in to comment.