views:

29

answers:

1

Is it possible to load a django template tag/filter to use as a function in one of my template tags?

I'm trying to load up some of the django.contrib.humanize filters so I can apply them to the results of some of my custom template tags. I can't seem to import them at all, and I don't want to have to rewrite any of that code.

+2  A: 

Template tags are just Python functions; you can import their module and call them with impunity, the only requirement being that you pass them appropriate arguments. The django.contrib.humanize.templatetags.humanize module has separate functions to do the work, so it's even easier in that specific case.

Ignacio Vazquez-Abrams
Hmm. That's what I was trying, I guess I just had the wrong import path every time I tried it. It works with 'from django.contrib.humanize.templatetags import humanize'. So, thanks.
Alex Jillard