From 118592663dcb761fb269ead3ab8a4977bc2cd3a6 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 3 Jan 2015 22:50:20 +0100 Subject: [PATCH] Exposed Engine in the django.template namespace. It's the main entrypoint to the refactored template system. --- django/template/__init__.py | 4 +++- django/template/engine.py | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/django/template/__init__.py b/django/template/__init__.py index 510b293e79..045ec72529 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -41,12 +41,14 @@ Shared: ### Multiple Template Engines +from .engine import Engine + from .utils import EngineHandler engines = EngineHandler() -__all__ = ('engines',) +__all__ = ('Engine', 'engines') ### Django Template Language diff --git a/django/template/engine.py b/django/template/engine.py index 9e9feb70fa..edd731a46c 100644 --- a/django/template/engine.py +++ b/django/template/engine.py @@ -7,7 +7,6 @@ from django.utils.deprecation import RemovedInDjango20Warning from django.utils.functional import cached_property from django.utils.module_loading import import_string -from . import engines from .base import Context, Lexer, Parser, Template, TemplateDoesNotExist from .context import _builtin_context_processors @@ -68,8 +67,10 @@ class Engine(object): >>> template.render(context) 'Hello world!' """ - # Since DjangoTemplates is a wrapper around this Engine class, a local - # import is mandatory to avoid an import loop. + # Since Engine is imported in django.template and since + # DjangoTemplates is a wrapper around this Engine class, + # local imports are required to avoid import loops. + from django.template import engines from django.template.backends.django import DjangoTemplates django_engines = [engine for engine in engines.all() if isinstance(engine, DjangoTemplates)]