Commit 556a7487 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Fixed a few uses of Template that relied on a default engine.

Refs #24389.
parent c688460d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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:
+2 −2
Original line number Diff line number Diff line
@@ -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(
+6 −4
Original line number Diff line number Diff line
@@ -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('.'):