mirror of https://github.com/django/django.git
Fixed #24685 -- Fixed check for template name unicity.
Thanks Preston Timmons for the report.
This commit is contained in:
parent
db0a0c4b8a
commit
1563b897c4
|
@ -50,6 +50,7 @@ class EngineHandler(object):
|
||||||
]
|
]
|
||||||
|
|
||||||
templates = OrderedDict()
|
templates = OrderedDict()
|
||||||
|
backend_names = []
|
||||||
for tpl in self._templates:
|
for tpl in self._templates:
|
||||||
tpl = tpl.copy()
|
tpl = tpl.copy()
|
||||||
try:
|
try:
|
||||||
|
@ -68,8 +69,9 @@ class EngineHandler(object):
|
||||||
tpl.setdefault('OPTIONS', {})
|
tpl.setdefault('OPTIONS', {})
|
||||||
|
|
||||||
templates[tpl['NAME']] = tpl
|
templates[tpl['NAME']] = tpl
|
||||||
|
backend_names.append(tpl['NAME'])
|
||||||
|
|
||||||
counts = Counter(list(templates))
|
counts = Counter(backend_names)
|
||||||
duplicates = [alias for alias, count in counts.most_common() if count > 1]
|
duplicates = [alias for alias, count in counts.most_common() if count > 1]
|
||||||
if duplicates:
|
if duplicates:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
|
|
|
@ -35,3 +35,12 @@ class TemplateStringsTests(SimpleTestCase):
|
||||||
engines.all()
|
engines.all()
|
||||||
with self.assertRaises(ImproperlyConfigured):
|
with self.assertRaises(ImproperlyConfigured):
|
||||||
engines.all()
|
engines.all()
|
||||||
|
|
||||||
|
@override_settings(TEMPLATES=[{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
}, {
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
}])
|
||||||
|
def test_backend_names_must_be_unique(self):
|
||||||
|
with self.assertRaises(ImproperlyConfigured):
|
||||||
|
engines.all()
|
||||||
|
|
Loading…
Reference in New Issue