1. Skip to navigation
  2. Skip to content

Entries tagged “tips”

Common Template Tags

written by Michael Trier, on Aug 7, 2007 12:04:00 AM.

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.