From 4e5bbb6ef2287126badd32842b239f4a8a7394ca Mon Sep 17 00:00:00 2001 From: Zain Patel Date: Sat, 24 Apr 2021 01:50:27 +0100 Subject: [PATCH] Fixed #32681 -- Fixed VariableDoesNotExist when rendering some admin template. Regression in 84609b3205905097d7d3038d32e6101f012c0619. --- AUTHORS | 1 + django/contrib/admin/options.py | 2 ++ django/contrib/admin/sites.py | 2 ++ docs/releases/3.2.1.txt | 3 +++ tests/admin_views/tests.py | 12 ++++++++++++ 5 files changed, 20 insertions(+) diff --git a/AUTHORS b/AUTHORS index f99a2c44ff..b76b825716 100644 --- a/AUTHORS +++ b/AUTHORS @@ -982,6 +982,7 @@ answer newbie questions, and generally made Django that much better: Zach Liu Zach Thompson Zain Memon + Zain Patel Zak Johnson Žan Anderle Zbigniew Siciarz diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 1eaf4d8227..a527e42c6d 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1890,6 +1890,7 @@ class ModelAdmin(BaseModelAdmin): context = { **self.admin_site.each_context(request), 'title': title, + 'subtitle': None, 'object_name': object_name, 'object': obj, 'deleted_objects': deleted_objects, @@ -1930,6 +1931,7 @@ class ModelAdmin(BaseModelAdmin): context = { **self.admin_site.each_context(request), 'title': _('Change history: %s') % obj, + 'subtitle': None, 'action_list': action_list, 'module_name': str(capfirst(opts.verbose_name_plural)), 'object': obj, diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index ba9b032914..837dabfea8 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -524,6 +524,7 @@ class AdminSite: context = { **self.each_context(request), 'title': self.index_title, + 'subtitle': None, 'app_list': app_list, **(extra_context or {}), } @@ -541,6 +542,7 @@ class AdminSite: context = { **self.each_context(request), 'title': _('%(app)s administration') % {'app': app_dict['name']}, + 'subtitle': None, 'app_list': [app_dict], 'app_label': app_label, **(extra_context or {}), diff --git a/docs/releases/3.2.1.txt b/docs/releases/3.2.1.txt index 07d449ae8d..f99dacac0c 100644 --- a/docs/releases/3.2.1.txt +++ b/docs/releases/3.2.1.txt @@ -56,3 +56,6 @@ Bugfixes with subqueries that began manifesting in Django 3.2, due to a separate fix using ``Exists`` to ``exclude()`` multi-valued relationships (:ticket:`32650`). + +* Fixed a bug in Django 3.2 where variable lookup errors were logged when + rendering some admin templates (:ticket:`32681`). diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 4ec1c90349..b1658941ee 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1121,6 +1121,18 @@ class AdminViewBasicTest(AdminViewBasicTestCase): response = self.client.get(reverse('admin:admin_views_city_add')) self.assertContains(response, 'overridden_name') + def test_render_views_no_subtitle(self): + tests = [ + reverse('admin:index'), + reverse('admin:app_list', args=('admin_views',)), + reverse('admin:admin_views_article_delete', args=(self.a1.pk,)), + reverse('admin:admin_views_article_history', args=(self.a1.pk,)), + ] + for url in tests: + with self.subTest(url=url): + with self.assertNoLogs('django.template', 'DEBUG'): + self.client.get(url) + @override_settings(TEMPLATES=[{ 'BACKEND': 'django.template.backends.django.DjangoTemplates',