Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved ModelAdmin.check_dependancies to AdminSite. Make debugging prob…

…lems why the admin is not working more apparent.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8274 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 89a8990a7663946cb80e696e595cbfbe553cac97 1 parent 65be568
@brosner brosner authored
Showing with 22 additions and 22 deletions.
  1. +1 −22 django/contrib/admin/options.py
  2. +21 −0 django/contrib/admin/sites.py
View
23 django/contrib/admin/options.py
@@ -5,7 +5,7 @@
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 @@ def __init__(self, model, admin_site):
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 @@ def __call__(self, request, url):
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
View
21 django/contrib/admin/sites.py
@@ -6,6 +6,7 @@
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 @@ def has_permission(self, request):
*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 @@ def root(self, request, url):
"""
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)
Please sign in to comment.
Something went wrong with that request. Please try again.