1. Skip to navigation
  2. Skip to content

Common Template Tags

I’m still enjoying the nuggets of goodness in the Django Master Class slides. I love this little tidbit:

from django import template
template.add_to_builtins(“myproject.templatetags.switchcase”)

If you have custom template tags that you want to make available in every template, put the above bit of code in a top level file that will get loaded on startup, such as __init__.py. I like it.


Discussion