-1

Originally I had just one app in my Django project, the templates consisted of an index.html a detail.html and a layout.html ... the index and detail files extended the layout. They all lived in the same directory ([app1]/templates/[app1]/) and it could find all the files fine.

Now I've got a second app, and I want to re-use the layout.html ... I decided to make a templates dir off the base of the django project, and put it in there. Here's what my directory structure looks like now:

<basepath>/<django_project>/templates/shared
<basepath>/<django_project>/<app1>/templates/<app1>
<basepath>/<django_project>/<app2>/templates/<app2>

I updated my settings.py:

TEMPLATE_DIRS = (
    '/full/path/to/<django_project>/<app1>/templates',
    '/full/path/to/<django_project>/<app2>/templates',
    '/full/path/to/<django_project>/templates',
)

In the 'shared' dir I have the layout.html ... from the app1 or app2 template dirs, I have the index.html and the 'extends' line at the top of the file reads:

{% extends "shared/layout.html" %}

However, when I try to load the apps view, it gets an error that it can't find shared/layout.html

TemplateSyntaxError at /
Caught TemplateDoesNotExist while rendering: shared/layout.html

Any ideas what I'm missing? This should be fairly straightforward, I must be overlooking something really obvious?

Nick Jennings
  • 3,853
  • 6
  • 30
  • 45
  • Might it be possible to show your TEMPLATE_LOADERS settings ? – Jonas Geiregat Jul 19 '12 at 13:54
  • Also note that if you have `django.template.loaders.app_directories.Loader` enabled in your setting's `TEMPLATE_LOADERS` (which is the default), then you don't need to add mention of your "per-application" template dirs in `TEMPLATE_DIRS`. – bruno desthuilliers Jul 19 '12 at 14:07
  • From the error page, what does the section "Django tried loading these templates, in this order:" says? – Noel Pure Jul 19 '12 at 14:07
  • 1
    NB! NEVER PUT YOUR APPLICATION DIRECTORIES IN YOUR TEMPLATE_DIRS SETTING. That's what the TEMPLATE_LOADERS are for. – benjaoming Jul 21 '12 at 18:56

1 Answers1

0

My bad! I thought I was running this behind Nginx, so I restarted that and was still having the problems. After re-checking I realized I was running behind Apache, restarting Apache updated my TEMPLATE_DIRS and now it works!

Nick Jennings
  • 3,853
  • 6
  • 30
  • 45