summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZain Patel <zain.patel@quantumblack.com>2021-04-24 01:50:27 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-26 12:52:33 +0200
commit0dfe88eaba551ab3ecec9a573d59e8d2fa3a8f94 (patch)
tree647d97e250ecdc01d56520295f51ab6eaeb6864e
parentfc9cbad880632e77a37957ba6686a72c2e7481e4 (diff)
[3.2.x] Fixed #32681 -- Fixed VariableDoesNotExist when rendering some admin template.
Regression in 84609b3205905097d7d3038d32e6101f012c0619. Backport of 4e5bbb6ef2287126badd32842b239f4a8a7394ca from main.
-rw-r--r--AUTHORS1
-rw-r--r--django/contrib/admin/options.py2
-rw-r--r--django/contrib/admin/sites.py2
-rw-r--r--docs/releases/3.2.1.txt3
-rw-r--r--tests/admin_views/tests.py13
5 files changed, 21 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index 6173351409..256118ae54 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -979,6 +979,7 @@ answer newbie questions, and generally made Django that much better:
Zach Liu <zachliu@gmail.com>
Zach Thompson <zthompson47@gmail.com>
Zain Memon
+ Zain Patel <zain.patel06@gmail.com>
Zak Johnson <zakj@nox.cx>
Žan Anderle <zan.anderle@gmail.com>
Zbigniew Siciarz <zbigniew@siciarz.net>
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index b286466fb5..c38901e874 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 600944ebc0..728e1cbf5e 100644
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -525,6 +525,7 @@ class AdminSite:
context = {
**self.each_context(request),
'title': self.index_title,
+ 'subtitle': None,
'app_list': app_list,
**(extra_context or {}),
}
@@ -542,6 +543,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 ad47c504c1..29b2283447 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -1117,6 +1117,19 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
self.assertContains(response, '<h1>View article</h1>')
self.assertContains(response, '<h2>Article 2</h2>')
+ 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.assertRaisesMessage(AssertionError, 'no logs'):
+ with self.assertLogs('django.template', 'DEBUG'):
+ self.client.get(url)
+
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',