Chris Pratt
Chris Pratt

Reputation: 239290

TemplateDoesNotExist error, but template does in fact exist

Vital stats: Ubuntu 11.04 Django 1.3.1

I'm running Haystack backed by Whoosh. The rest of the site functions fine, but when I attempt to search, I get a TemplateDoesNotExist exception for a template included in templates/search/search.html. The template loader is obviously able to read search.html, or it wouldn't know to try to fetch the include. The included file, _resultPage.html is in the same directory, has the same permissions and same owner and group as search.html. And, it's not just this one include. If I comment it out, it simply errors out on the next included file.

Any ideas?

Upvotes: 1

Views: 2288

Answers (2)

okm
okm

Reputation: 23871

The include tag relies on django.template.loader.get_template which searches templates in normal way instead of by relative path. Do you use "_resultPage.html" or "search/_resultPage.html". If you use the first form, the absolute path of 'template/search/search' must be in TEMPLATE_DIRS. You could check by doing the following:

>>> from django.template.loader import get_template
>>> get_template('_resultPage.html')

Upvotes: 2

Chris Pratt
Chris Pratt

Reputation: 239290

I was under a time crunch, so I simply rolled all the included templates right into search.html and called it a day.

Upvotes: 0

Related Questions