summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2008-08-09 23:40:57 +0000
committerBrian Rosner <brosner@gmail.com>2008-08-09 23:40:57 +0000
commit89a8990a7663946cb80e696e595cbfbe553cac97 (patch)
tree1b16f6b5b8fa587fbcd5231739023a7ea1a7d6a1
parent65be56816fc173f823566728ab78b72d061bb466 (diff)
Moved ModelAdmin.check_dependancies to AdminSite. Make debugging problems why the admin is not working more apparent.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8274 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/options.py23
-rw-r--r--django/contrib/admin/sites.py21
2 files changed, 22 insertions, 22 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 3128de4af7..90a817c0f1 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -5,7 +5,7 @@ from django.forms.models import BaseInlineFormSet
from django.contrib.contenttypes.models import ContentType
from django.contrib.admin import widgets
from django.contrib.admin.util import quote, unquote, get_deleted_objects
-from django.core.exceptions import ImproperlyConfigured, PermissionDenied
+from django.core.exceptions import PermissionDenied
from django.db import models, transaction
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render_to_response
@@ -262,10 +262,6 @@ class ModelAdmin(BaseModelAdmin):
super(ModelAdmin, self).__init__()
def __call__(self, request, url):
- from django.conf import settings
- if settings.DEBUG:
- self.check_dependancies()
-
# Delegate to the appropriate method, based on the URL.
if url is None:
return self.changelist_view(request)
@@ -278,23 +274,6 @@ class ModelAdmin(BaseModelAdmin):
else:
return self.change_view(request, unquote(url))
- def check_dependancies(self):
- """
- Check that all things needed to run the admin have been correctly installed.
-
- The default implementation checks that LogEntry, ContentType and the
- auth context processor are installed.
- """
- from django.conf import settings
- from django.contrib.admin.models import LogEntry
-
- if not LogEntry._meta.installed:
- raise ImproperlyConfigured("Put 'django.contrib.admin' in your INSTALLED_APPS setting in order to use the admin application.")
- if not ContentType._meta.installed:
- raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in your INSTALLED_APPS setting in order to use the admin application.")
- if 'django.core.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
- raise ImproperlyConfigured("Put 'django.core.context_processors.auth' in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")
-
def _media(self):
from django.conf import settings
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index a83d8ec4d9..6477029fca 100644
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -6,6 +6,7 @@ from django import http, template
from django.contrib.admin import ModelAdmin
from django.contrib.auth import authenticate, login
from django.db.models.base import ModelBase
+from django.core.exceptions import ImproperlyConfigured
from django.shortcuts import render_to_response
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
@@ -112,6 +113,23 @@ class AdminSite(object):
*at least one* page in the admin site.
"""
return request.user.is_authenticated() and request.user.is_staff
+
+ def check_dependancies(self):
+ """
+ Check that all things needed to run the admin have been correctly installed.
+
+ The default implementation checks that LogEntry, ContentType and the
+ auth context processor are installed.
+ """
+ from django.conf import settings
+ from django.contrib.admin.models import LogEntry
+
+ if not LogEntry._meta.installed:
+ raise ImproperlyConfigured("Put 'django.contrib.admin' in your INSTALLED_APPS setting in order to use the admin application.")
+ if not ContentType._meta.installed:
+ raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in your INSTALLED_APPS setting in order to use the admin application.")
+ if 'django.core.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS:
+ raise ImproperlyConfigured("Put 'django.core.context_processors.auth' in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")
def root(self, request, url):
"""
@@ -121,6 +139,9 @@ class AdminSite(object):
"""
if request.method == 'GET' and not request.path.endswith('/'):
return http.HttpResponseRedirect(request.path + '/')
+
+ if settings.DEBUG:
+ self.check_dependancies()
# Figure out the admin base URL path and stash it for later use
self.root_path = re.sub(re.escape(url) + '$', '', request.path)