开发者

Load and Reuse Django Template Filters

开发者 https://www.devze.com 2022-12-17 04:44 出处:网络
Is it possible to load a django开发者_Go百科 template tag/filter to use as a function in one of my template tags?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号