From 525e1e379af20e53819b3b34b27380eb27ca0ac8 Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Fri, 1 Aug 2008 19:10:55 +0000 Subject: [PATCH] Fixed #7922 -- admin.autodiscover() no longer eats ImportErrors for breakfast. Thanks Jan Rademaker and Alex Gaynor for their work on the ticket. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8174 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/__init__.py b/django/contrib/admin/__init__.py index 56b64faacb..ef3b40af33 100644 --- a/django/contrib/admin/__init__.py +++ b/django/contrib/admin/__init__.py @@ -8,9 +8,12 @@ def autodiscover(): not present. This forces an import on them to register any admin bits they may want. """ + import imp from django.conf import settings for app in settings.INSTALLED_APPS: try: - __import__("%s.admin" % app) + imp.find_module("admin", app.split(".")) except ImportError: - pass + # there is no admin.py in app, skip it. + continue + __import__("%s.admin" % app)