Avoided exceptions in a non-critical check in the admin.
This change makes it possible to configure several Django template engines in a project and still use the admin. On the flip side the check is silently skipped when no Django template engine is configured.
This commit is contained in:
parent
6b5113ec94
commit
3bba4b420e
|
@ -168,14 +168,25 @@ class AdminSite(object):
|
||||||
installed, as well as the auth context processor.
|
installed, as well as the auth context processor.
|
||||||
"""
|
"""
|
||||||
if not apps.is_installed('django.contrib.admin'):
|
if not apps.is_installed('django.contrib.admin'):
|
||||||
raise ImproperlyConfigured("Put 'django.contrib.admin' in "
|
raise ImproperlyConfigured(
|
||||||
"your INSTALLED_APPS setting in order to use the admin application.")
|
"Put 'django.contrib.admin' in your INSTALLED_APPS "
|
||||||
|
"setting in order to use the admin application.")
|
||||||
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(
|
||||||
"your INSTALLED_APPS setting in order to use the admin application.")
|
"Put 'django.contrib.contenttypes' in your INSTALLED_APPS "
|
||||||
if 'django.contrib.auth.context_processors.auth' not in Engine.get_default().context_processors:
|
"setting in order to use the admin application.")
|
||||||
raise ImproperlyConfigured("Enable 'django.contrib.auth.context_processors.auth' "
|
try:
|
||||||
"in your TEMPLATES setting in order to use the admin application.")
|
default_template_engine = Engine.get_default()
|
||||||
|
except ImproperlyConfigured:
|
||||||
|
# Skip the check if the user has a non-trivial TEMPLATES setting
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if ('django.contrib.auth.context_processors.auth'
|
||||||
|
not in default_template_engine.context_processors):
|
||||||
|
raise ImproperlyConfigured(
|
||||||
|
"Enable 'django.contrib.auth.context_processors.auth' "
|
||||||
|
"in your TEMPLATES setting in order to use the admin "
|
||||||
|
"application.")
|
||||||
|
|
||||||
def admin_view(self, view, cacheable=False):
|
def admin_view(self, view, cacheable=False):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue