0个评论 1人收藏此文章

 

Note: The results are rounded to an integer before returning, so this may have marginal utility for many cases.

So, in summary:

to compute A*B: {% widthratio A 1 B %} 
to compute A/B: {% widthratio AB 1 %}

And, since add is a filter and not a tag, you can always to crazy stuff like:

compute A^2: {% widthratio A 1 A %} 
compute (A+B)^2: {% widthratio A|add:B 1 A|add:B %} 
compute (A+B) * (C+D): {% widthratio A|add:B 1 C|add:D %}

原文出处:http://slacy.com/blog/2010/07/using-djangos-widthratio-template-tag-for-multiplication-division/

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2021-10-07
猜你喜欢
  • 2022-12-23
  • 2021-09-08
  • 2021-10-10
  • 2021-08-01
  • 2021-12-30
相关资源
相似解决方案