tags:

views:

43

answers:

1

I realize that templatetags are mainly used specific to applications which are INSTALLED_APPS, such as articles/templatetags/, but in my case I need tags for generic things such as navigation which doesn't have an application.

I'm currently keeping templatetags in my project dir. and in order for it to get picked up I added my project to INSTALLED_APPS - this works but I'm not sure if this was the right thing to do - are there any downsides?

+2  A: 

I would do it the same way Django provides its additional template tags, i.e. creating an own package/application( django.contrib.humanize, django.contrib.markup, django.contrib.webdesign)

These are just three "normal" packages, that have a templatetags package inside. The name of the module inside tempaltetags is the same as the package/application name (e.g. humanize.py).

Then put it somewhere where Python can find it.

You could also create some kind of "meta" package templatetags and put everything there, e.g.

templatetags
 - navigation
   - __init__.py
   - templatetags
      - _init__.py
      - navigation.py
 - other
  - ...

Of course you have to add those to you INSTALLED_APPS (e.g. templatetags.navigation) and load them in your template (e.g.{% load navigation %}`).

Felix Kling