在Django模板中重新定义默认过滤行为 [英] redefine default filtering behavior in Django templates
问题描述
decimal.Decimal(10.0000)。normalize()
我没有找到一种更改默认渲染系统的方法。我知道有一个人性化和一个floatformat过滤器我可以在我的模板中使用。但是我需要一个解决方案,并不意味着编辑所有这些文件,即使可以写一个shell脚本。
谢谢
解决方案我终于想出了这个答案问题并发布在我的博客中:
http://tothinkornottothink.com/post/2156476872 / django-positivenormalizeddecimalfield
我希望有人觉得有用
I have a project with many DecimalFields that are rendered in more than 300 templates. I would like that these decimal fields are rendered normalized. I don't care about precission or anything:
decimal.Decimal("10.0000").normalize()
I haven't found a way to change default rendering system. I know there is a humanize and a floatformat filter I could use in my templates. But I need a solution that doesn't mean editing all those files, even if a shell script could be written.
Thanks
解决方案 I finally came up with the answer to this question and posted it in my blog:
http://tothinkornottothink.com/post/2156476872/django-positivenormalizeddecimalfield
I hope somebody finds it useful
这篇关于在Django模板中重新定义默认过滤行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!