contrib admin and admindocs problem

381 views
Skip to first unread message

Michael Graz

unread,
Oct 10, 2008, 4:45:41 PM10/10/08
to django...@googlegroups.com
Greetings,

The contrib.admin module depends on the contrib.admindocs module due to "{% url django-admindocs-docroot as docsroot %}" being part of the admin base.html template.  However there is a problem with the following usage:

urlpatterns = patterns('',
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    (r'^admin/(.*)', admin.site.root),
)

The include('django.contrib.admindocs.urls') is done only on demand (a lazy evaluation).  So if the "/admin" url is visited virst there is some kind of weird TemplateSyntaxError since admin template doesn't know about the named url from admindocs.  But once the "/admin/doc" url is visited then the django.contrib.admindocs.urls are loaded and the url named django-admindocs-docroot springs into existence.  Then from that point on the "/admin" will render successfully.

Is there a way to have the "/admin" url work right from the start without first having to visit the "/admin/doc" url?  This problem occurs after every server restart.  If the server is rarely restarted then the problem is lessened.  However during development it happens every time the manage.py reloads due to a file being changed.

Any assistance appreciated!  Many thanks,
-Mike

Karen Tracey

unread,
Oct 10, 2008, 7:40:28 PM10/10/08
to django...@googlegroups.com

I do not see this behavior. Specifics of the "weird TemplateSyntaxError" might shed some light.  I have the urls you specify in my config (and 'django.contrib.admindocs' in INSTALLED_APPS) and can surely visit /admin without problem before ever visiting the doc url.

Karen

Nash

unread,
Oct 12, 2008, 6:51:15 AM10/12/08
to Django users
I get this error, you can see a paste here: http://dpaste.com/83932/
The admin site doesn't work on production at all, on the testserver it
works after a refresh.

On Oct 11, 4:40 am, "Karen Tracey" <kmtra...@gmail.com> wrote:

James Bennett

unread,
Oct 12, 2008, 6:58:35 AM10/12/08
to django...@googlegroups.com
On Sun, Oct 12, 2008 at 5:51 AM, Nash <nasr...@gmail.com> wrote:
> I get this error, you can see a paste here: http://dpaste.com/83932/
> The admin site doesn't work on production at all, on the testserver it
> works after a refresh.

You appear to have an error in your own code, as evidenced by the
final line of the traceback (when in doubt, always *read* the error
message):

"Tried view_form in module px.heroes.views. Error was: 'module' object
has no attribute 'view_form'"

This says that your code tries to access something named "view_form"
in the module "px.heroes.views", but that there is no such thing
available. This raises an exception, which breaks everything.

(and the reason why you see this in the admin is because the admin
uses reverse URL resolution, which means it has to be able to import
all of your views -- any error, anywhere, in any of your views, will
break everything)


--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

Michael Graz

unread,
Oct 13, 2008, 5:12:38 PM10/13/08
to django...@googlegroups.com
Yes, my original analysis was wrong.  The problem was due to a non-existing function specified as url handler.
Thanks,
-Mike
Reply all
Reply to author
Forward
0 new messages