Is there a filter for divide for Django Template?

前端 未结 6 1873
囚心锁ツ
囚心锁ツ 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:31

    I would use a custom template, but if you don't want to you can use the widthratio built in tag,

    {% widthratio request.session.get_expiry_age 3600 1 %} 
    

    Another example

    {% widthratio value 1150000 100 %}
    

    Syntax:

    {% widthratio parm1 parm2 parm3 %}
    

    So basically its used for scaling images, but you can use it for division. What it does is: parm1/parm2 * parm3.

    Hope this helps, more on widthratio here.

提交回复
热议问题