From fd1dd767783b5a7ec1a594fcc5885e7e4178dd26 Mon Sep 17 00:00:00 2001 From: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:01:10 +0200 Subject: [PATCH] Fixed #35716 -- Fixed VariableDoesNotExist when rendering admin fieldsets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regression in 01ed59f753139afb514170ee7f7384c155ecbc2d. Thank you to Fábio Domingues and Marijke Luttekes for the report, and thank you to Natalia Bidart for the review. --- django/contrib/admin/templates/admin/change_form.html | 2 +- .../contrib/admin/templates/admin/edit_inline/stacked.html | 2 +- .../contrib/admin/templates/admin/includes/fieldset.html | 2 +- docs/releases/5.1.1.txt | 3 +++ tests/admin_inlines/tests.py | 7 +++++++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html index 31ff5d6c10..09ef954e5c 100644 --- a/django/contrib/admin/templates/admin/change_form.html +++ b/django/contrib/admin/templates/admin/change_form.html @@ -47,7 +47,7 @@ {% block field_sets %} {% for fieldset in adminform %} - {% include "admin/includes/fieldset.html" with heading_level=2 id_suffix=forloop.counter0 %} + {% include "admin/includes/fieldset.html" with heading_level=2 prefix="fieldset" id_prefix=0 id_suffix=forloop.counter0 %} {% endfor %} {% endblock %} diff --git a/django/contrib/admin/templates/admin/edit_inline/stacked.html b/django/contrib/admin/templates/admin/edit_inline/stacked.html index 73f459ee47..a6939f4ea2 100644 --- a/django/contrib/admin/templates/admin/edit_inline/stacked.html +++ b/django/contrib/admin/templates/admin/edit_inline/stacked.html @@ -26,7 +26,7 @@ {% with parent_counter=forloop.counter0 %} {% for fieldset in inline_admin_form %} - {% include "admin/includes/fieldset.html" with heading_level=4 id_prefix=parent_counter id_suffix=forloop.counter0 %} + {% include "admin/includes/fieldset.html" with heading_level=4 prefix=fieldset.formset.prefix id_prefix=parent_counter id_suffix=forloop.counter0 %} {% endfor %} {% endwith %} diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html b/django/contrib/admin/templates/admin/includes/fieldset.html index b4eef47547..a9d3f92702 100644 --- a/django/contrib/admin/templates/admin/includes/fieldset.html +++ b/django/contrib/admin/templates/admin/includes/fieldset.html @@ -1,4 +1,4 @@ -{% with prefix=fieldset.formset.prefix|default:"fieldset" id_prefix=id_prefix|default:"0" id_suffix=id_suffix|default:"0" name=fieldset.name|default:""|slugify %} +{% with name=fieldset.name|default:""|slugify %}