diff --git a/django/template/base.py b/django/template/base.py index 2917d8323d..42c0047079 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -1264,13 +1264,12 @@ class Library(object): _dict = func(*resolved_args, **resolved_kwargs) if not getattr(self, 'nodelist', False): - from django.template.loader import get_template, select_template if isinstance(file_name, Template): t = file_name elif not isinstance(file_name, six.string_types) and is_iterable(file_name): - t = select_template(file_name) + t = context.engine.select_template(file_name) else: - t = get_template(file_name) + t = context.engine.get_template(file_name) self.nodelist = t.nodelist new_context = context_class(_dict, **{ 'autoescape': context.autoescape, diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py index 5bd0d27428..b41b1ea4c3 100644 --- a/django/template/loader_tags.py +++ b/django/template/loader_tags.py @@ -2,7 +2,6 @@ from collections import defaultdict from django.template.base import TemplateSyntaxError, Library, Node, TextNode,\ token_kwargs, Variable -from django.template.loader import get_template from django.utils.safestring import mark_safe from django.utils import six @@ -102,7 +101,7 @@ class ExtendsNode(Node): raise TemplateSyntaxError(error_msg) if hasattr(parent, 'render'): return parent # parent is a Template object - return get_template(parent) + return context.engine.get_template(parent) def render(self, context): compiled_parent = self.get_parent(context) @@ -143,7 +142,7 @@ class IncludeNode(Node): # Does this quack like a Template? if not callable(getattr(template, 'render', None)): # If not, we'll try get_template - template = get_template(template) + template = context.engine.get_template(template) values = { name: var.resolve(context) for name, var in six.iteritems(self.extra_context) diff --git a/django/template/loaders/base.py b/django/template/loaders/base.py index bbcdd3aec2..6c6706206c 100644 --- a/django/template/loaders/base.py +++ b/django/template/loaders/base.py @@ -1,5 +1,4 @@ from django.template.base import TemplateDoesNotExist -from django.template.loader import get_template_from_string class Loader(object): @@ -21,7 +20,7 @@ class Loader(object): template_name, template_dirs) try: - template = get_template_from_string(source, origin, template_name) + template = self.engine.from_string(source, origin, template_name) except TemplateDoesNotExist: # If compiling the template we found raises TemplateDoesNotExist, # back off to returning the source and display name for the diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py index fd058e1eaa..8b053aed42 100644 --- a/django/template/loaders/cached.py +++ b/django/template/loaders/cached.py @@ -5,7 +5,6 @@ to load templates from them in order, caching the result. import hashlib from django.template.base import TemplateDoesNotExist -from django.template.loader import get_template_from_string from django.utils.encoding import force_bytes from .base import Loader as BaseLoader @@ -62,7 +61,7 @@ class Loader(BaseLoader): template, origin = self.find_template(template_name, template_dirs) if not hasattr(template, 'render'): try: - template = get_template_from_string(template, origin, template_name) + template = self.engine.from_string(template, origin, template_name) except TemplateDoesNotExist: # If compiling the template we found raises TemplateDoesNotExist, # back off to returning the source and display name for the template