diff options
| author | Aymeric Augustin <aymeric.augustin@oscaro.com> | 2015-02-22 19:14:05 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@oscaro.com> | 2015-02-22 23:13:55 +0100 |
| commit | 556a74879f5c2d382927b5b68451c76d344e29e4 (patch) | |
| tree | 31a9fa4251fc5433bf6fd44cdbb2de7348bc2d08 | |
| parent | c688460df6239539d2b5a1fc8c51778086fe7c35 (diff) | |
Fixed a few uses of Template that relied on a default engine.
Refs #24389.
| -rw-r--r-- | django/core/management/templates.py | 4 | ||||
| -rw-r--r-- | django/views/i18n.py | 4 | ||||
| -rw-r--r-- | django/views/static.py | 10 |
3 files changed, 10 insertions, 8 deletions
diff --git a/django/core/management/templates.py b/django/core/management/templates.py index 22391c721e..eb5340dc88 100644 --- a/django/core/management/templates.py +++ b/django/core/management/templates.py @@ -13,7 +13,7 @@ from os import path import django from django.core.management.base import BaseCommand, CommandError from django.core.management.utils import handle_extensions -from django.template import Context, Template +from django.template import Context, Engine from django.utils import archive from django.utils.six.moves.urllib.request import urlretrieve from django.utils.version import get_docs_version @@ -147,7 +147,7 @@ class TemplateCommand(BaseCommand): content = template_file.read() if filename.endswith(extensions) or filename in extra_files: content = content.decode('utf-8') - template = Template(content) + template = Engine().from_string(content) content = template.render(context) content = content.encode('utf-8') with open(new_path, 'wb') as new_file: diff --git a/django/views/i18n.py b/django/views/i18n.py index 11ce8c6293..7e21035319 100644 --- a/django/views/i18n.py +++ b/django/views/i18n.py @@ -6,7 +6,7 @@ import os from django import http from django.apps import apps from django.conf import settings -from django.template import Context, Template +from django.template import Context, Engine from django.utils import six from django.utils._os import upath from django.utils.encoding import smart_text @@ -178,7 +178,7 @@ js_catalog_template = r""" def render_javascript_catalog(catalog=None, plural=None): - template = Template(js_catalog_template) + template = Engine().from_string(js_catalog_template) indent = lambda s: s.replace('\n', '\n ') context = Context({ 'catalog_str': indent(json.dumps( diff --git a/django/views/static.py b/django/views/static.py index 1ff36bc8e9..9959b96236 100644 --- a/django/views/static.py +++ b/django/views/static.py @@ -14,7 +14,7 @@ from django.http import ( FileResponse, Http404, HttpResponse, HttpResponseNotModified, HttpResponseRedirect, ) -from django.template import Context, Template, TemplateDoesNotExist, loader +from django.template import Context, Engine, TemplateDoesNotExist, loader from django.utils.http import http_date, parse_http_date from django.utils.six.moves.urllib.parse import unquote from django.utils.translation import ugettext as _, ugettext_lazy @@ -102,10 +102,12 @@ template_translatable = ugettext_lazy("Index of %(directory)s") def directory_index(path, fullpath): try: - t = loader.select_template(['static/directory_index.html', - 'static/directory_index']) + t = loader.select_template([ + 'static/directory_index.html', + 'static/directory_index', + ]) except TemplateDoesNotExist: - t = Template(DEFAULT_DIRECTORY_INDEX_TEMPLATE, name='Default directory index template') + t = Engine().from_string(DEFAULT_DIRECTORY_INDEX_TEMPLATE) files = [] for f in os.listdir(fullpath): if not f.startswith('.'): |
