mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #33800 -- Fixed system check for the same template tag module in installed apps and template tag libraries.
Thanks Claude Paroz for the report.
Regression in 004b4620f6.
			
			
This commit is contained in:
		| @@ -50,15 +50,15 @@ def check_string_if_invalid_is_string(app_configs, **kwargs): | ||||
| @register(Tags.templates) | ||||
| def check_for_template_tags_with_the_same_name(app_configs, **kwargs): | ||||
|     errors = [] | ||||
|     libraries = defaultdict(list) | ||||
|     libraries = defaultdict(set) | ||||
|  | ||||
|     for conf in settings.TEMPLATES: | ||||
|         custom_libraries = conf.get("OPTIONS", {}).get("libraries", {}) | ||||
|         for module_name, module_path in custom_libraries.items(): | ||||
|             libraries[module_name].append(module_path) | ||||
|             libraries[module_name].add(module_path) | ||||
|  | ||||
|     for module_name, module_path in get_template_tag_modules(): | ||||
|         libraries[module_name].append(module_path) | ||||
|         libraries[module_name].add(module_path) | ||||
|  | ||||
|     for library_name, items in libraries.items(): | ||||
|         if len(items) > 1: | ||||
| @@ -66,7 +66,7 @@ def check_for_template_tags_with_the_same_name(app_configs, **kwargs): | ||||
|                 Error( | ||||
|                     E003.msg.format( | ||||
|                         repr(library_name), | ||||
|                         ", ".join(repr(item) for item in items), | ||||
|                         ", ".join(repr(item) for item in sorted(items)), | ||||
|                     ), | ||||
|                     id=E003.id, | ||||
|                 ) | ||||
|   | ||||
| @@ -158,6 +158,19 @@ class CheckTemplateTagLibrariesWithSameName(SimpleTestCase): | ||||
|                 [self.error_same_tags], | ||||
|             ) | ||||
|  | ||||
|     @override_settings( | ||||
|         INSTALLED_APPS=["check_framework.template_test_apps.same_tags_app_1"] | ||||
|     ) | ||||
|     def test_template_tags_same_library_in_installed_apps_libraries(self): | ||||
|         with self.settings( | ||||
|             TEMPLATES=[ | ||||
|                 self.get_settings( | ||||
|                     "same_tags", "same_tags_app_1.templatetags.same_tags" | ||||
|                 ), | ||||
|             ] | ||||
|         ): | ||||
|             self.assertEqual(check_for_template_tags_with_the_same_name(None), []) | ||||
|  | ||||
|     @override_settings( | ||||
|         INSTALLED_APPS=["check_framework.template_test_apps.same_tags_app_1"] | ||||
|     ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user