Thursday, November 19, 2009

Django template does not exist

I got a really annoying error while putting up a new Django site:

TemplateDoesNotExist
at /flatpage/
flatpages/default.html
Request Method: GET
Request URL: http://[site url]/flatpage/
Exception Type: TemplateDoesNotExist
Exception Value:
flatpages/default.html
Exception Location: /usr/lib/python2.4/site-packages/django/template/loader.py in find_template_source, line 74
Python Executable: /usr/bin/python
Python Version: 2.4.3
Python Path: ['/[python path]', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages']
Server time: Thu, 19 Nov 2009 22:39:37 -0500
Of course I had templates in Apache's directory. The Template-loader postmortem (great name) showed that Django was looking for the wrong directory (in italics below.)

Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.load_template_source:
/[development path]/flatpages/default.html (File does not exist)
Using loader django.template.loaders.app_directories.load_template_source:
/usr/lib/python2.4/site-packages/django/contrib/admin/templates/flatpages/default.html (File does not exist)
I know these things should be put into properties. I was being lazy.

I restarted the server to clear out whatever had cashed the older directory entry. Everything was fine.

Nice!

No comments: