mirror of https://github.com/django/django.git
Refs #32987 -- Relaxed system check for template tag modules with the same name by turning into a warning.
Thanks Claude Paroz for the report.
Regression in 004b4620f6
.
This commit is contained in:
parent
3b4a5b9f97
commit
f71b0cf769
|
@ -4,7 +4,7 @@ from collections import defaultdict
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template.backends.django import get_template_tag_modules
|
from django.template.backends.django import get_template_tag_modules
|
||||||
|
|
||||||
from . import Error, Tags, register
|
from . import Error, Tags, Warning, register
|
||||||
|
|
||||||
E001 = Error(
|
E001 = Error(
|
||||||
"You have 'APP_DIRS': True in your TEMPLATES but also specify 'loaders' "
|
"You have 'APP_DIRS': True in your TEMPLATES but also specify 'loaders' "
|
||||||
|
@ -15,7 +15,7 @@ E002 = Error(
|
||||||
"'string_if_invalid' in TEMPLATES OPTIONS must be a string but got: {} ({}).",
|
"'string_if_invalid' in TEMPLATES OPTIONS must be a string but got: {} ({}).",
|
||||||
id="templates.E002",
|
id="templates.E002",
|
||||||
)
|
)
|
||||||
E003 = Error(
|
W003 = Warning(
|
||||||
"{} is used for multiple template tag modules: {}",
|
"{} is used for multiple template tag modules: {}",
|
||||||
id="templates.E003",
|
id="templates.E003",
|
||||||
)
|
)
|
||||||
|
@ -63,12 +63,12 @@ def check_for_template_tags_with_the_same_name(app_configs, **kwargs):
|
||||||
for library_name, items in libraries.items():
|
for library_name, items in libraries.items():
|
||||||
if len(items) > 1:
|
if len(items) > 1:
|
||||||
errors.append(
|
errors.append(
|
||||||
Error(
|
Warning(
|
||||||
E003.msg.format(
|
W003.msg.format(
|
||||||
repr(library_name),
|
repr(library_name),
|
||||||
", ".join(repr(item) for item in sorted(items)),
|
", ".join(repr(item) for item in sorted(items)),
|
||||||
),
|
),
|
||||||
id=E003.id,
|
id=W003.id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -553,6 +553,9 @@ configured:
|
||||||
:setting:`OPTIONS <TEMPLATES-OPTIONS>` must be a string but got: ``{value}``
|
:setting:`OPTIONS <TEMPLATES-OPTIONS>` must be a string but got: ``{value}``
|
||||||
(``{type}``).
|
(``{type}``).
|
||||||
* **templates.E003**:``<name>`` is used for multiple template tag modules:
|
* **templates.E003**:``<name>`` is used for multiple template tag modules:
|
||||||
|
``<module list>``. *This check was changed to* ``templates.W003`` *in Django
|
||||||
|
4.1.2*.
|
||||||
|
* **templates.W003**:``<name>`` is used for multiple template tag modules:
|
||||||
``<module list>``.
|
``<module list>``.
|
||||||
|
|
||||||
Translation
|
Translation
|
||||||
|
|
|
@ -47,3 +47,6 @@ Bugfixes
|
||||||
* Reverted caching related managers for ``ForeignKey``, ``ManyToManyField``,
|
* Reverted caching related managers for ``ForeignKey``, ``ManyToManyField``,
|
||||||
and ``GenericRelation`` that caused the incorrect refreshing of related
|
and ``GenericRelation`` that caused the incorrect refreshing of related
|
||||||
objects (:ticket:`33984`).
|
objects (:ticket:`33984`).
|
||||||
|
|
||||||
|
* Relaxed the system check added in Django 4.1 for the same name used for
|
||||||
|
multiple template tag modules to a warning (:ticket:`32987`).
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
from copy import copy, deepcopy
|
from copy import copy, deepcopy
|
||||||
|
|
||||||
from django.core.checks import Error
|
from django.core.checks import Warning
|
||||||
from django.core.checks.templates import (
|
from django.core.checks.templates import (
|
||||||
E001,
|
E001,
|
||||||
E002,
|
E002,
|
||||||
E003,
|
W003,
|
||||||
check_for_template_tags_with_the_same_name,
|
check_for_template_tags_with_the_same_name,
|
||||||
check_setting_app_dirs_loaders,
|
check_setting_app_dirs_loaders,
|
||||||
check_string_if_invalid_is_string,
|
check_string_if_invalid_is_string,
|
||||||
|
@ -108,15 +108,15 @@ class CheckTemplateTagLibrariesWithSameName(SimpleTestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
cls.error_same_tags = Error(
|
cls.warning_same_tags = Warning(
|
||||||
E003.msg.format(
|
W003.msg.format(
|
||||||
"'same_tags'",
|
"'same_tags'",
|
||||||
"'check_framework.template_test_apps.same_tags_app_1."
|
"'check_framework.template_test_apps.same_tags_app_1."
|
||||||
"templatetags.same_tags', "
|
"templatetags.same_tags', "
|
||||||
"'check_framework.template_test_apps.same_tags_app_2."
|
"'check_framework.template_test_apps.same_tags_app_2."
|
||||||
"templatetags.same_tags'",
|
"templatetags.same_tags'",
|
||||||
),
|
),
|
||||||
id=E003.id,
|
id=W003.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -139,7 +139,7 @@ class CheckTemplateTagLibrariesWithSameName(SimpleTestCase):
|
||||||
def test_template_tags_with_same_name(self):
|
def test_template_tags_with_same_name(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
check_for_template_tags_with_the_same_name(None),
|
check_for_template_tags_with_the_same_name(None),
|
||||||
[self.error_same_tags],
|
[self.warning_same_tags],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_template_tags_with_same_library_name(self):
|
def test_template_tags_with_same_library_name(self):
|
||||||
|
@ -155,7 +155,7 @@ class CheckTemplateTagLibrariesWithSameName(SimpleTestCase):
|
||||||
):
|
):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
check_for_template_tags_with_the_same_name(None),
|
check_for_template_tags_with_the_same_name(None),
|
||||||
[self.error_same_tags],
|
[self.warning_same_tags],
|
||||||
)
|
)
|
||||||
|
|
||||||
@override_settings(
|
@override_settings(
|
||||||
|
@ -186,15 +186,15 @@ class CheckTemplateTagLibrariesWithSameName(SimpleTestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
check_for_template_tags_with_the_same_name(None),
|
check_for_template_tags_with_the_same_name(None),
|
||||||
[
|
[
|
||||||
Error(
|
Warning(
|
||||||
E003.msg.format(
|
W003.msg.format(
|
||||||
"'same_tags'",
|
"'same_tags'",
|
||||||
"'check_framework.template_test_apps.different_tags_app."
|
"'check_framework.template_test_apps.different_tags_app."
|
||||||
"templatetags.different_tags', "
|
"templatetags.different_tags', "
|
||||||
"'check_framework.template_test_apps.same_tags_app_1."
|
"'check_framework.template_test_apps.same_tags_app_1."
|
||||||
"templatetags.same_tags'",
|
"templatetags.same_tags'",
|
||||||
),
|
),
|
||||||
id=E003.id,
|
id=W003.id,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue