On Thu, Apr 14, 2011 at 4:50 PM, Yuka Poppe <y...@xs4all.nl> wrote:

> Hi Jeff,
>
> I think Gladys is correct, the reason for your code finding the index
> template, is because its probably looking for 'myapp/index.html'
> instead of just 'index.html'
>
> Im not really sure if you're also distinguishing between the project
> template root and the app directory template dirs.
>
> Generally this would be how the template directories would be layed out:
>
> /whatever/templates
> /whatever/myproject/myapp/templates
> /whatever/myproject/mysecondapp/templates
>
> First django looks in the templates set in your settings.py
> (/whatever/templates) then, depending on the order in installed apps,
> it looks at <app_dir>/templates
>
>
> So when you try to extend just 'base.html' it tries
> /whatever/templates/base.html,
> /whatever/myproject/myapp/templates/base.html, /whatever/my.. etc.
> regardless of wheter or not the template where you are including from
> is in the same directory. So again, why your index.html is working and
> extending base.html doesnt work is in my best guess, due to the fact
> that your code was looking for 'myapp/index.html' and the template
> tried to include just 'base.html', which you said was located in
> 'myapp'
>
> Take note that if you do try to extend 'myapp/base.html' for the app
> based template directories, it would actually look in
> /whatever/myproject/myapp/templates/myapp/base.html, this might seem
> confusing at first.
>
> Hope this helps, Yuka
>
> On Thu, Apr 14, 2011 at 10:38 PM, Jeff Blaine <cjbla...@gmail.com> wrote:
> > Gladys,
> > On Thursday, April 14, 2011 4:12:29 PM UTC-4, gladys wrote:
> > The root directory for your templates is in  '/whatever/myproject', so
> >>
> >> of course it will look for your base.html here.
> >> Now if your base is in another location, say "/whatever/myproject/
> >> myapp/base.html", your extends should look like this:
> >> {% extends "myapp/base.html" %}.
> >
> > First, thanks for the reply.
> > It's finding my /myproject/myapp/index.html template (the one that calls
> > "base.html"), so something clearly knows about where to find my
> templates,
> > yet "extend" looks elsewhere.
> > That is, if I make /myproject/myapp/index.html to be completely
> > self-contained, it is found and loaded fine.
> > If I change it to {% extend "base.html" %}, it can't find that referenced
> > template.
> >
> > That seems broken to me.
> > I tried your suggestion above (the other day, and again now) in
> > /myproject/myapp/index.html
> > {% extend "myapp/base.html" %}
> >
> > It does not work:
> >     Caught TemplateDoesNotExist while rendering: myapp/base.html
> > ALSO... I changed the following from:
> > TEMPLATE_DIRS = (
> >     '/myproject',
> > )
> >
> > to:
> > TEMPLATE_DIRS = (
> >     '/myproject/myapp',
> > )
> >
> > Which then results in failure to find even /myproject/myapp/index.html
> >     TemplateDoesNotExist at /
> >
> >
> >>
> >> Best of Luck.
> >>
> >> --
> >> Gladys
> >> http://blog.bixly.com
> >>
> >>
> >> On Apr 15, 3:56 am, Jeff Blaine <cjbl...@gmail.com> wrote:
> >> > Django 1.3
> >> >
> >> > Hi all,
> >> >
> >> > I can't seem to get around this.  It appears that, the following
> >> > "index.html" template in */whatever/myproject/myapp*
> >> >
> >> > {% extends "base.html %}
> >> > <!-- stuff here -->
> >> >
> >> > Looks for base.html as /whatever/myproject/base.html instead
> >> > of /whatever/myproject/myapp/base.html
> >> >
> >> > My TEMPLATE_DIRS is set as follows, and with this setting, the
> >> > */whatever/myproject/myapp/index.html
> >> > template is loaded fine* if I make it self-contained (not extending)
> >> >
> >> > TEMPLATE_DIRS = (
> >> >     '/whatever/myproject',
> >> > )
> >> >
> >> > Any ideas?
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
In settings.py you have this:

>> > TEMPLATE_DIRS = (
>> >     '/whatever/myproject',
>> > )
>

Note it says "DIRS", and its a tuple.  Add the other paths to where you want
to look for templates.

The way I've done my template layout is to have a template directory under
the project, then subdirectories for each app.

When you specify a template that is project level, you just use its name.
For app specific templates you specify like: "app1/mytemplate.html"


-- 
Joel Goldstick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to