Template loader cannot find admin_doc templates

458 views
Skip to first unread message

Piper

unread,
Sep 15, 2011, 3:39:13 PM9/15/11
to Django users
Hello,

I tried enabling the admin_doc system in Django 1.3.1 and I got a
TemplateDoesNotExist exception as follows:

[CUT]
TemplateDoesNotExist at /admin/doc/

admin_doc/missing_docutils.html

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/doc/
Django Version: 1.3.1
Exception Type: TemplateDoesNotExist
Exception Value:

admin_doc/missing_docutils.html

Exception Location: C:\users\Piper\projs\pystuff\lib\site-packages
\django\template\loader.py in find_template, line 138
Python Executable: C:\users\Piper\projs\pystuff\Scripts\python.exe
Python Version: 2.7.1
[/CUT]


My urls.py has the following:
[CUT]
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'cms.views.home', name='home'),
# url(r'^cms/', include('cms.foo.urls')),

# Uncomment the admin/doc line below to enable admin
documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'', include('django.contrib.flatpages.urls')),

)
[/CUT]


And settings.py has the following in the templates section:

[CUT]
# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

# more settings... and later:

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.

os.path.join(PROJECT_DIR, 'templates'),
)
[/CUT]


where PROJECT_DIR = os.path.dirname(__file__) and that is set earlier
in top of the settings file.

Some of the details of the TemplateDoesNotExist exception reported
above are as follows:

[CUT]
Server time: Thu, 15 Sep 2011 21:57:58 +0300
Template-loader postmortem

Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.Loader:
c:\users\Piper\projs\djprojs\cms\templates\admin_doc
\missing_docutils.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
c:\users\Piper\projs\pystuff\lib\site-packages\django\contrib
\admin\templates\admin_doc\missing_docutils.html (File does not exist)
[/CUT]


I understand that the first location Django tries is the path I gave
in the settings file for my project's own templates, but the second
location that Django tries seems odd to me.

The actual template directory (and actual file) is in
contrib.admindocs:
C:\Users\Piper\projs\pystuff\Lib\site-packages\django\contrib\admindocs
\templates\admin_doc

Not in the subdirectory of contrib.admin:
c:\users\Piper\projs\pystuff\lib\site-packages\django\contrib\admin
\templates\admin_doc\


Why is Django searching the admin subdirectory instead of admindocs'
for the templates of the latter? Any thoughts?


Piper

unread,
Sep 15, 2011, 11:29:32 PM9/15/11
to Django users
Solved by adding 'django.contrib.admindocs' to the INSTALLED_APPS.

James Bennett

unread,
Sep 15, 2011, 11:33:48 PM9/15/11
to django...@googlegroups.com
On Thu, Sep 15, 2011 at 8:29 PM, Piper <yhd...@yahoo.com> wrote:
> Solved by adding 'django.contrib.admindocs' to the INSTALLED_APPS.

Worth noting that this is the first thing you're instructed to do in
the documentation for the admin docs system:

https://docs.djangoproject.com/en/1.3/ref/contrib/admin/admindocs/

Might be a good idea to double-check the rest of your setup against
that to make sure nothing else is missing.


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

Piper

unread,
Sep 16, 2011, 1:04:08 AM9/16/11
to Django users
On Sep 16, 6:33 am, James Bennett <ubernost...@gmail.com> wrote:
> Worth noting that this is the first thing you're instructed to do in
> the documentation for the admin docs system:
>
> https://docs.djangoproject.com/en/1.3/ref/contrib/admin/admindocs/
>
> Might be a good idea to double-check the rest of your setup against
> that to make sure nothing else is missing.


Thanks James. Even when the Documentation system seemed to be working
now, I took your advice and double checked. The instructions I read,
however, seem somewhat confusing and in some areas lacking. I could be
mistaken, so I hope someone can help me out to understand how all this
works.

In the link above one reads:
------------------
1. "Optional: Linking to templates requires the ADMIN_FOR setting to
be configured."
------------------

To the best of my knowledge, the templates seem to be working now--
after all I no longer receive TemplateDoesNotExist exceptions anymore
(is that not an indication that the linking is up and running?)-- yet
I have not set the ADMIN_FOR in my settings file. So why say the
linking "requires" it, when it seems not to?

It continues:
------------------
2. "Optional: Using the admindocs bookmarklets requires the
XViewMiddleware to be installed."
------------------

I searched the locally generated sphinx Django docs and googled to
find the only reference to admindocs bookmarklets is from where I
quote it above (i.e. there is no explanation as to what it is and what
it actually does), so I don't know if and why I want to use them; but
if I assume they are a kind of helper system to organize references
that developers might find important, then kindly allow me to suggest
that instructions as to how to install the XViewMiddleware are missing
from the django docs.

One has to grep the django source to see that "XViewMiddleware" is
defined in "django\middleware\doc.py" and has to google it to see that
inserting 'django.middleware.doc.XViewMiddleware' in
MIDDLEWARE_CLASSES [1] is probably the right way to install it.
Shouldn't that be in the docs?

Best regards


[1] http://code.google.com/appengine/articles/django.html
Reply all
Reply to author
Forward
0 new messages