mirror of https://github.com/django/django.git
Removed direct references to template-related settings.
This commit is contained in:
parent
6294bd3903
commit
18533fb558
|
@ -7,6 +7,7 @@ from django.db.models.base import ModelBase
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
|
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
|
||||||
from django.core.urlresolvers import reverse, NoReverseMatch
|
from django.core.urlresolvers import reverse, NoReverseMatch
|
||||||
|
from django.template.engine import Engine
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.text import capfirst
|
from django.utils.text import capfirst
|
||||||
|
@ -170,7 +171,7 @@ class AdminSite(object):
|
||||||
if not apps.is_installed('django.contrib.contenttypes'):
|
if not apps.is_installed('django.contrib.contenttypes'):
|
||||||
raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in "
|
raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in "
|
||||||
"your INSTALLED_APPS setting in order to use the admin application.")
|
"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' "
|
raise ImproperlyConfigured("Put 'django.contrib.auth.context_processors.auth' "
|
||||||
"in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")
|
"in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ from django.core.exceptions import ViewDoesNotExist
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.core import urlresolvers
|
from django.core import urlresolvers
|
||||||
from django.contrib.admindocs import utils
|
from django.contrib.admindocs import utils
|
||||||
|
from django.template.engine import Engine
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.utils._os import upath
|
from django.utils._os import upath
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
@ -291,13 +292,13 @@ class TemplateDetailView(BaseAdminDocsView):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
template = self.kwargs['template']
|
template = self.kwargs['template']
|
||||||
templates = []
|
templates = []
|
||||||
for dir in settings.TEMPLATE_DIRS:
|
for dir in Engine.get_default().dirs:
|
||||||
template_file = os.path.join(dir, template)
|
template_file = os.path.join(dir, template)
|
||||||
templates.append({
|
templates.append({
|
||||||
'file': template_file,
|
'file': template_file,
|
||||||
'exists': os.path.exists(template_file),
|
'exists': os.path.exists(template_file),
|
||||||
'contents': lambda: open(template_file).read() if os.path.exists(template_file) else '',
|
'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({
|
kwargs.update({
|
||||||
'name': template,
|
'name': template,
|
||||||
|
|
|
@ -276,14 +276,16 @@ class ExceptionReporter(object):
|
||||||
def get_traceback_data(self):
|
def get_traceback_data(self):
|
||||||
"""Return a dictionary containing traceback information."""
|
"""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):
|
if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist):
|
||||||
self.template_does_not_exist = True
|
self.template_does_not_exist = True
|
||||||
self.loader_debug_info = []
|
self.loader_debug_info = []
|
||||||
# If Django fails in get_template_loaders, provide an empty list
|
# If Django fails in get_template_loaders, provide an empty list
|
||||||
# for the following loop to not fail.
|
# for the following loop to not fail.
|
||||||
try:
|
try:
|
||||||
# TODO: handle multiple template engines.
|
template_loaders = template_engine.template_loaders
|
||||||
template_loaders = Engine.get_default().template_loaders
|
|
||||||
except Exception:
|
except Exception:
|
||||||
template_loaders = []
|
template_loaders = []
|
||||||
for loader in template_loaders:
|
for loader in template_loaders:
|
||||||
|
@ -302,7 +304,7 @@ class ExceptionReporter(object):
|
||||||
'loader': loader_name,
|
'loader': loader_name,
|
||||||
'templates': template_list,
|
'templates': template_list,
|
||||||
})
|
})
|
||||||
if (settings.TEMPLATE_DEBUG and
|
if (template_engine.debug and
|
||||||
hasattr(self.exc_value, 'django_template_source')):
|
hasattr(self.exc_value, 'django_template_source')):
|
||||||
self.get_template_exception_info()
|
self.get_template_exception_info()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue