0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

Removed direct references to template-related settings.

This commit is contained in:
Aymeric Augustin 2014-11-22 21:43:13 +01:00
parent 6294bd3903
commit 18533fb558
3 changed files with 10 additions and 6 deletions

View File

@ -7,6 +7,7 @@ from django.db.models.base import ModelBase
from django.apps import apps
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.core.urlresolvers import reverse, NoReverseMatch
from django.template.engine import Engine
from django.template.response import TemplateResponse
from django.utils import six
from django.utils.text import capfirst
@ -170,7 +171,7 @@ class AdminSite(object):
if not apps.is_installed('django.contrib.contenttypes'):
raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in "
"your INSTALLED_APPS setting in order to use the admin application.")
if 'django.contrib.auth.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
if 'django.contrib.auth.context_processors.auth' not in Engine.get_default().context_processors:
raise ImproperlyConfigured("Put 'django.contrib.auth.context_processors.auth' "
"in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")

View File

@ -13,6 +13,7 @@ from django.core.exceptions import ViewDoesNotExist
from django.http import Http404
from django.core import urlresolvers
from django.contrib.admindocs import utils
from django.template.engine import Engine
from django.utils.decorators import method_decorator
from django.utils._os import upath
from django.utils import six
@ -291,13 +292,13 @@ class TemplateDetailView(BaseAdminDocsView):
def get_context_data(self, **kwargs):
template = self.kwargs['template']
templates = []
for dir in settings.TEMPLATE_DIRS:
for dir in Engine.get_default().dirs:
template_file = os.path.join(dir, template)
templates.append({
'file': template_file,
'exists': os.path.exists(template_file),
'contents': lambda: open(template_file).read() if os.path.exists(template_file) else '',
'order': list(settings.TEMPLATE_DIRS).index(dir),
'order': list(Engine.get_default().dirs).index(dir),
})
kwargs.update({
'name': template,

View File

@ -276,14 +276,16 @@ class ExceptionReporter(object):
def get_traceback_data(self):
"""Return a dictionary containing traceback information."""
# TODO: handle multiple template engines.
template_engine = Engine.get_default()
if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist):
self.template_does_not_exist = True
self.loader_debug_info = []
# If Django fails in get_template_loaders, provide an empty list
# for the following loop to not fail.
try:
# TODO: handle multiple template engines.
template_loaders = Engine.get_default().template_loaders
template_loaders = template_engine.template_loaders
except Exception:
template_loaders = []
for loader in template_loaders:
@ -302,7 +304,7 @@ class ExceptionReporter(object):
'loader': loader_name,
'templates': template_list,
})
if (settings.TEMPLATE_DEBUG and
if (template_engine.debug and
hasattr(self.exc_value, 'django_template_source')):
self.get_template_exception_info()