Is there a filter for divide for Django Template?

前端 未结 6 1879
囚心锁ツ
囚心锁ツ 2020-12-20 11:01

I noticed there is built-in add filter, but I wasn\'t able to find divide.

I am new to Django and not sure if there is a such filter.

6条回答
  •  情歌与酒
    2020-12-20 11:35

    There is a Python module to do math operations in your templates: Django-Mathfilters.

    It contains add as you said, but also div to divide:

     8 / 3 = {{ 8|div:3 }}
    

提交回复
热议问题