Load and Reuse Django Template Filters
Is it possible to load a django开发者_Go百科 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.
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.
精彩评论