Преглед на файлове

Removed direct references to template-related settings.

Aymeric Augustin преди 10 години
родител
ревизия
18533fb558
променени са 3 файла, в които са добавени 10 реда и са изтрити 6 реда
  1. 2 1
      django/contrib/admin/sites.py
  2. 3 2
      django/contrib/admindocs/views.py
  3. 5 3
      django/views/debug.py

+ 2 - 1
django/contrib/admin/sites.py

@@ -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.")
 

+ 3 - 2
django/contrib/admindocs/views.py

@@ -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,

+ 5 - 3
django/views/debug.py

@@ -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()