On Thu, Jan 1, 2009 at 8:18 AM, Alan <alanwil...@gmail.com> wrote:
> Happy new year List!
> So, I have in a project several apps and they basically use the same
> templatetags. I found out by luck that I just need to define it in one
> application, something like:
> app1/
> models.py
> ...
> app2/
> templatetags/mytags.py
> models.py
> ...
> and app1 will use mytags.
> Is my inference right? Well it's working here. If so, why templatetags has
> to be inside apps folder? Why not at the same level of 'template' folder?
> It sounds inconsistent to me, or I am probably missing something here.

Your usage is correct i.e., you only need to define the template tag
once. However, I'm a little confused as to why you see it as
inconsistent.

Templates will tend to be site/project specific, so it makes sense
that templates aren't associated with the individual applications
inside a project. Hence, projects tend to have a top level templates
directory that are independent of the applications in use.

Template Tags, on the other hand, are just blocks of code, so they
need to be reusable. The unit of reusability in Django is the
application. A template tag is defined as being part of App2, but that
is really just a way of getting the template tag registered - it
doesn't limit the places where the template tag can be used.

The possible source of confusion is that there isn't any namespacing
of template tags - there is only the single global templatetag
namespace. Introducing namespaces for template tags is a subject that
gets raised occasionally - search the archives and the ticket database
if you want to see the state of play of that discussion.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
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