diff --git a/django/core/management/templates.py b/django/core/management/templates.py index 6648fafde9..275b2100aa 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._os import rmtree_errorhandler from django.utils.six.moves.urllib.request import urlretrieve @@ -148,7 +148,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 9bb97e147a..e10cb764df 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('.'):