autodiscover not being called? why?

8 views
Skip to first unread message

bongo

unread,
Jan 6, 2009, 8:36:19 AM1/6/09
to Django users
I am in the process of upgrading an old django 0.96 application to
1.0.2 final.

I am having real trouble getting the admin app to run with my models
included with the new method. After some trial an error it seems that
autodiscover is never being called at all in my urls.py. However, the
url mappings are working. Any one got an idea as to why django might
not be running autodiscover?

from django.contrib import admin

admin.autodiscover()
print "Discovered!"

urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root),
....


Thanks
John

Valts Mazurs

unread,
Jan 6, 2009, 9:31:04 AM1/6/09
to django...@googlegroups.com
1. Check your settings.py if it uses the correct urls.py file. Actually at first check if the correct settings.py is being used
2. Remove .pyc and pyo files from your project's directory to be sure that python interpreter really takes into account changes in source files.

Regards,
--
Valts

bongo

unread,
Jan 6, 2009, 9:43:20 AM1/6/09
to Django users
Thanks. It is still not working but probably for another reason (maybe
I have put the admin.py in wrong directory or something).

Your tip of deleting all the pyc files now results in "Discovered!"
being printed so I think autodiscover is actually being run now. Its
strange but I thought modifying the urls.py source would cause a new
pyc file to be created. I wonder why does that not happen?

Where does the new autodiscover actually look for relevant admin.py
files?

On Jan 6, 2:31 pm, "Valts Mazurs" <vald...@gmail.com> wrote:
> 1. Check your settings.py if it uses the correct urls.py file. Actually at
> first check if the correct settings.py is being used
> 2. Remove .pyc and pyo files from your project's directory to be sure that
> python interpreter really takes into account changes in source files.
>
> Regards,
> --
> Valts
>

Karen Tracey

unread,
Jan 6, 2009, 12:14:17 PM1/6/09
to django...@googlegroups.com
On Tue, Jan 6, 2009 at 9:43 AM, bongo <jo...@jdiligence.com> wrote:

Thanks. It is still not working but probably for another reason (maybe
I have put the admin.py in wrong directory or something).

Your tip of deleting all the pyc files now results in "Discovered!"
being printed so I think autodiscover is actually being run now. Its
strange but I thought modifying the urls.py source would cause a new
pyc file to be created. I wonder why does that not happen?

No idea.
 

Where does the new autodiscover actually look for relevant admin.py
files?

In your application directory, the one created by manage.py startapp, same as where models.py is.

Karen

bongo

unread,
Jan 6, 2009, 1:06:54 PM1/6/09
to Django users

> In your application directory, the one created by manage.py startapp, same
> as where models.py is.

Thanks.

Thats what I thought I should put it. This is getting weirder though.
Even though I got autodiscover working it still couldn't find it. I
then decided to go with the manual method of subclassing the admin app
and manually wiring it in according to this blog.

http://oebfare.com/blog/2008/jul/20/newforms-admin-migration-and-screencast/

It still didn't work but now with an import name error.

Its seems that when I renamed the module from admin.py to
adrem_admin.py it worked without an import error!

This is crazy but it simply didn't like the module being called
admin.py!! What is going on? A naming conflict with something in my
python installation? I assume it was trying to load the site
attribute from another module called admin somewhere.. ouch! How can I
find out what it was really finding?

This has been driving me crazy for days. I now have a manual
workaround but it means the autodiscover will never work for me.. I
need to eliminate the real problem if I am ever to use autodiscover.

Valts Mazurs

unread,
Jan 7, 2009, 4:01:41 AM1/7/09
to django...@googlegroups.com
Check the output of:

import sys
print sys.modules['admin']

--
Valts
Reply all
Reply to author
Forward
0 new messages