mirror of
				https://github.com/django/django.git
				synced 2025-10-29 08:36:09 +00:00 
			
		
		
		
	[3.2.x] Fixed #32681 -- Fixed VariableDoesNotExist when rendering some admin template.
Regression in84609b3205. Backport of4e5bbb6ef2from main.
This commit is contained in:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							fc9cbad880
						
					
				
				
					commit
					0dfe88eaba
				
			
							
								
								
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -979,6 +979,7 @@ answer newbie questions, and generally made Django that much better: | |||||||
|     Zach Liu <zachliu@gmail.com> |     Zach Liu <zachliu@gmail.com> | ||||||
|     Zach Thompson <zthompson47@gmail.com> |     Zach Thompson <zthompson47@gmail.com> | ||||||
|     Zain Memon |     Zain Memon | ||||||
|  |     Zain Patel <zain.patel06@gmail.com> | ||||||
|     Zak Johnson <zakj@nox.cx> |     Zak Johnson <zakj@nox.cx> | ||||||
|     Žan Anderle <zan.anderle@gmail.com> |     Žan Anderle <zan.anderle@gmail.com> | ||||||
|     Zbigniew Siciarz <zbigniew@siciarz.net> |     Zbigniew Siciarz <zbigniew@siciarz.net> | ||||||
|   | |||||||
| @@ -1890,6 +1890,7 @@ class ModelAdmin(BaseModelAdmin): | |||||||
|         context = { |         context = { | ||||||
|             **self.admin_site.each_context(request), |             **self.admin_site.each_context(request), | ||||||
|             'title': title, |             'title': title, | ||||||
|  |             'subtitle': None, | ||||||
|             'object_name': object_name, |             'object_name': object_name, | ||||||
|             'object': obj, |             'object': obj, | ||||||
|             'deleted_objects': deleted_objects, |             'deleted_objects': deleted_objects, | ||||||
| @@ -1930,6 +1931,7 @@ class ModelAdmin(BaseModelAdmin): | |||||||
|         context = { |         context = { | ||||||
|             **self.admin_site.each_context(request), |             **self.admin_site.each_context(request), | ||||||
|             'title': _('Change history: %s') % obj, |             'title': _('Change history: %s') % obj, | ||||||
|  |             'subtitle': None, | ||||||
|             'action_list': action_list, |             'action_list': action_list, | ||||||
|             'module_name': str(capfirst(opts.verbose_name_plural)), |             'module_name': str(capfirst(opts.verbose_name_plural)), | ||||||
|             'object': obj, |             'object': obj, | ||||||
|   | |||||||
| @@ -525,6 +525,7 @@ class AdminSite: | |||||||
|         context = { |         context = { | ||||||
|             **self.each_context(request), |             **self.each_context(request), | ||||||
|             'title': self.index_title, |             'title': self.index_title, | ||||||
|  |             'subtitle': None, | ||||||
|             'app_list': app_list, |             'app_list': app_list, | ||||||
|             **(extra_context or {}), |             **(extra_context or {}), | ||||||
|         } |         } | ||||||
| @@ -542,6 +543,7 @@ class AdminSite: | |||||||
|         context = { |         context = { | ||||||
|             **self.each_context(request), |             **self.each_context(request), | ||||||
|             'title': _('%(app)s administration') % {'app': app_dict['name']}, |             'title': _('%(app)s administration') % {'app': app_dict['name']}, | ||||||
|  |             'subtitle': None, | ||||||
|             'app_list': [app_dict], |             'app_list': [app_dict], | ||||||
|             'app_label': app_label, |             'app_label': app_label, | ||||||
|             **(extra_context or {}), |             **(extra_context or {}), | ||||||
|   | |||||||
| @@ -56,3 +56,6 @@ Bugfixes | |||||||
|   with subqueries that began manifesting in Django 3.2, due to a separate fix |   with subqueries that began manifesting in Django 3.2, due to a separate fix | ||||||
|   using ``Exists`` to ``exclude()`` multi-valued relationships |   using ``Exists`` to ``exclude()`` multi-valued relationships | ||||||
|   (:ticket:`32650`). |   (:ticket:`32650`). | ||||||
|  |  | ||||||
|  | * Fixed a bug in Django 3.2 where variable lookup errors were logged when | ||||||
|  |   rendering some admin templates (:ticket:`32681`). | ||||||
|   | |||||||
| @@ -1117,6 +1117,19 @@ class AdminViewBasicTest(AdminViewBasicTestCase): | |||||||
|         self.assertContains(response, '<h1>View article</h1>') |         self.assertContains(response, '<h1>View article</h1>') | ||||||
|         self.assertContains(response, '<h2>Article 2</h2>') |         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=[{ | @override_settings(TEMPLATES=[{ | ||||||
|     'BACKEND': 'django.template.backends.django.DjangoTemplates', |     'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user