Opened 16 years ago

Last modified 13 years ago

#8126 closed

admin.autodiscover() fails on bogus INSTALLED_APPS entries — at Version 9

Reported by: Beetle_B Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jacob)

Update: the real issue is that bogus entries in INSTALLED_APPS don't fail so well. Original ticket follows. —JKM

Revision 8185: Everything works fine.

8186 and current revision (8219) won't work unless I comment out admin.autodiscover(). There actually was a bug with one of my admin.py's, but now that's been fixed - the problem remains. I can import all my admin.py's from the shell just fine.

In fact, I even tried removing all my admin.py files. But admin.autodiscover() still kills everything. Traceback is not helpful:

 Request URL: http://127.0.0.1:8000/projects/
Django Version: 1.0-alpha-SVN-8219
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.markup',
 'collab.registration',
 'django.core.mail',
 'django.contrib.admin',
 'collab.profiles',
 'collab.project',
 'collab.teleconference',
 'collab.action',
 'collab.issues']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'collab.collab_middleware.CheckProfileExistence',
 'collab.collab_middleware.RemoveAnonymousMessage')


Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
  78.                     request.path_info)
File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
  238.             for pattern in self.urlconf_module.urlpatterns:
File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_urlconf_module
  262.                 raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e)

Exception Type: ImproperlyConfigured at /projects/
Exception Value: Error while importing URLconf 'collab.urls': 'module' object has no attribute '__path__'

Ideas?

Change History (9)

comment:1 by Karen Tracey <kmtracey@…>, 16 years ago

Resolution: worksforme
Status: newclosed

This has got to be caused by something specific to your setup, because plenty of people (well, at least me) are running on revs >= [8186] without error. I've followed up on your mailing list thread with an idea for narrowing down what the problem is, let's try to deal with it on the mailing list until/if it's determined that there's actually a bug in Django code.

comment:2 by Beetle_B, 16 years ago

Thought I might as well post the results here as well in case anyone else, one day, has this problem.

As per suggestion on django-users, I tried running admin.autodiscover from the shell. The output:

/usr/lib/python2.5/site-packages/django/contrib/admin/__init__.py in autodiscover()
     13     for app in settings.INSTALLED_APPS:
     14         try:
---> 15             imp.find_module("admin", __import__(app, {}, {}, [app.split(".")[-1]]).__path__)
     16         except ImportError:
     17             # there is no app admin.py, skip it

AttributeError: 'module' object has no attribute '__path__'

comment:3 by Beetle_B, 16 years ago

Resolution: worksforme
Status: closedreopened

From django-users:

OK, that's Django code. Go ahead and re-open the ticket I closed worksforme
with that info and details of what exactly you've got in INSTALLED_APPS
please.

My traceback in the original ticket summary shows my INSTALLED_APPS. However, I'm sure that's not much help to you. What information do you need?

Do note that this error occurs even with no admin.py files (or rather, after I delete all of them).

comment:4 by Jacob, 16 years ago

Yeah, admin.autodiscover is being far too clever here.

comment:5 by Beetle_B, 16 years ago

OK. I narrowed it down. I commented out most of the apps and tried admin.autodiscover() from the shell. Apparently django.core.mail is the culprit - it's in my apps. Apparently I put it there long ago for django-registration, although I'm not sure it needs to be there.

I take it this is my error?

comment:6 by Alex Gaynor, 16 years ago

django.core.mail definitely doesn't need to be there, and that's almost definitely causing the problem.

comment:7 by Beetle_B, 16 years ago

Resolution: invalid
Status: reopenedclosed

comment:8 by Karen Tracey <kmtracey@…>, 16 years ago

Resolution: invalid
Status: closedreopened

Even if it's a user error, couldn't that line of code in autodiscover() be a bit smarter? I suppose we could all learn that "'module' object has no attribute '__path__'" means "check INSTALLED_APPS for bogus entries" but I'm reopening the ticket to see if the admin code here can't be improved a bit...at least raise a more helpful error message?

comment:9 by Jacob, 16 years ago

Description: modified (diff)
Summary: revision 8186 killed my admin. Commenting out admin.autodiscover() "works".admin.autodiscover() fails on bogus INSTALLED_APPS entries

(updated ticket with real reason)

Note: See TracTickets for help on using tickets.
Back to Top