mozillazg's Blog
  • Feed
  • About
  • Archives

[django]在模板中对变量作减法操作

2013-02-25

django Tags django / python

我们知道可以使用内置过滤器 add 对变量做加法操作:

{{ 3|add:"1" }}   # 4

其实,add 也可以做减法操作:

{{ 3|add:"-1" }}  # 2

参考

  • Variable subtraction in django templates - Stack Overflow

有任何建议和想法欢迎在下方评论区留言或者加我微信交流

Related Posts:

  • [django]通过自定义 Model Field 的方式将上传的文本文件按 UTF-8 编码保存
  • [django]修复 "TypeError: delete() got an unexpected keyword argument 'using'"
  • [django]修复 "dictionary update sequence element 0 has length 1, 2 is required"
  • [django]按天分组统计数据
  • [django]按小时分组统计数据

Comments


© 2025 mozillazg · Powered by pelican-bootstrap3, Pelican, Bootstrap · Privacy

Creative Commons License "mozillazg's Blog" by mozillazg is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where indicated otherwise.

Back to top