diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-05-03 21:42:56 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-05-04 07:39:28 +0200 |
| commit | 1f0a6082ec42db09a0c2ead3227150b833a73168 (patch) | |
| tree | 7738b8bd4fb63f05cc783163df28b05ce7f7872f | |
| parent | 0c79932881a5b10f83a68a67dc15d2928f40e35d (diff) | |
[1.8.x] Fixed #24685 -- Fixed check for template name unicity.
Thanks Preston Timmons for the report.
Backport of 1563b89 from master
| -rw-r--r-- | django/template/utils.py | 4 | ||||
| -rw-r--r-- | tests/template_backends/test_utils.py | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/django/template/utils.py b/django/template/utils.py index 514df91a0c..ea72a8c5b1 100644 --- a/django/template/utils.py +++ b/django/template/utils.py @@ -50,6 +50,7 @@ class EngineHandler(object): ] templates = OrderedDict() + backend_names = [] for tpl in self._templates: tpl = tpl.copy() try: @@ -68,8 +69,9 @@ class EngineHandler(object): tpl.setdefault('OPTIONS', {}) 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] if duplicates: raise ImproperlyConfigured( diff --git a/tests/template_backends/test_utils.py b/tests/template_backends/test_utils.py index 3d2de99015..c3eb6577a0 100644 --- a/tests/template_backends/test_utils.py +++ b/tests/template_backends/test_utils.py @@ -35,3 +35,12 @@ class TemplateStringsTests(SimpleTestCase): engines.all() with self.assertRaises(ImproperlyConfigured): 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() |
