Code

Ticket #7922: autodiscover.2.diff

File autodiscover.2.diff, 728 bytes (added by Alex, 6 years ago)

Updated, this should work.

Line 
1diff --git a/django/contrib/admin/__init__.py b/django/contrib/admin/__init__.py
2index 56b64fa..56777d1 100644
3--- a/django/contrib/admin/__init__.py
4+++ b/django/contrib/admin/__init__.py
5@@ -8,9 +8,12 @@ def autodiscover():
6     not present. This forces an import on them to register any admin bits they
7     may want.
8     """
9+    import imp
10     from django.conf import settings
11     for app in settings.INSTALLED_APPS:
12         try:
13-            __import__("%s.admin" % app)
14+            imp.find_module('admin', __import__(app, fromlist=[app.split('.')[-1]]).__path__)
15         except ImportError:
16-            pass
17+            # There is no admin.py, skip it
18+            continue
19+        __import__('%s.admin' % app)