List Info

Thread: Templates for Custom Template Tags




Templates for Custom Template Tags
country flaguser name
United States
2007-09-30 15:17:56
I created a custom inclusion tag that makes use of a
template file
named menu_tag.html.  I placed that file in the app's
subdirectory of
the template directory.

When I tried to make use of it I got a template does not
exist
error.

I was able to resolve this by adding the app's subdirectory
to the
TEMPLATE_DIRS path.

However, it was my understanding that as long as
django.template.loaders.app_directories.load_template_source
was
included in the TEMPLATE_LOADERS (which it is), Django
would
automatically look in the subdirectories of the installed
apps.  This
functionality seems to be working for other template files,
just not
the ones from my custom tag.

Is it possible that this is because I placed the custom tag
in the
base.html that was in the root template directory rather
that used in
one of the app's template files?

Any clarification would be great.

Thanks,

Steve


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


Re: Templates for Custom Template Tags
country flaguser name
United States
2007-09-30 15:58:24
You need to place your tag templates into the subdirectory
called
"templates" of your application directory.
In that case
django.template.loaders.app_directories.load_template_source
would be
able to found your custom tag template. And you don't need
to add this
directory's path to TEMPLATE_DIRS variable.


On Sep 30, 1:17 pm, Steve  Potter <steven.pot...gmail.com> wrote:
> I created a custom inclusion tag that makes use of a
template file
> named menu_tag.html.  I placed that file in the app's
subdirectory of
> the template directory.
>
> When I tried to make use of it I got a template does
not exist
> error.
>
> I was able to resolve this by adding the app's
subdirectory to the
> TEMPLATE_DIRS path.
>
> However, it was my understanding that as long as
>
django.template.loaders.app_directories.load_template_source
was
> included in the TEMPLATE_LOADERS (which it is), Django
would
> automatically look in the subdirectories of the
installed apps.  This
> functionality seems to be working for other template
files, just not
> the ones from my custom tag.
>
> Is it possible that this is because I placed the custom
tag in the
> base.html that was in the root template directory
rather that used in
> one of the app's template files?
>
> Any clarification would be great.
>
> Thanks,
>
> Steve


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


Re: Templates for Custom Template Tags
country flaguser name
United States
2007-09-30 17:59:20
I was misunderstanding where the app_directories loader
looks for
files.  It makes sense now.

Thanks,

Steve


On Sep 30, 3:58 pm, AndrewK <pri...gmail.com> wrote:
> You need to place your tag templates into the
subdirectory called
> "templates" of your application directory.
> In that case
>
django.template.loaders.app_directories.load_template_source
would be
> able to found your custom tag template. And you don't
need to add this
> directory's path to TEMPLATE_DIRS variable.
>
> On Sep 30, 1:17 pm, Steve  Potter <steven.pot...gmail.com> wrote:
>
> > I created a custom inclusion tag that makes use of
a template file
> > named menu_tag.html.  I placed that file in the
app's subdirectory of
> > the template directory.
>
> > When I tried to make use of it I got a template
does not exist
> > error.
>
> > I was able to resolve this by adding the app's
subdirectory to the
> > TEMPLATE_DIRS path.
>
> > However, it was my understanding that as long as
> >
django.template.loaders.app_directories.load_template_source
was
> > included in the TEMPLATE_LOADERS (which it is),
Django would
> > automatically look in the subdirectories of the
installed apps.  This
> > functionality seems to be working for other
template files, just not
> > the ones from my custom tag.
>
> > Is it possible that this is because I placed the
custom tag in the
> > base.html that was in the root template directory
rather that used in
> > one of the app's template files?
>
> > Any clarification would be great.
>
> > Thanks,
>
> > Steve


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


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )