add float number in template (django)

倾然丶 夕夏残阳落幕 提交于 2019-12-24 01:53:23

问题


Maybe i'm missing something but i'm looking to add a float number, something like this:

{%floatnumber|add:3.4%}

Filter add round my result so I don't want to write my filter, but if is the only way, i'll copy add filter

Now i'm doing this:

def addf(value, arg):
    """Adds the arg to the value."""
    return float(value) + float(arg)
addf.is_safe = False
register.filter(addf)

回答1:


Right now it turns it into int. There is an open ticket and I even sent a patch, but it haven't been commited yet ;-) Here is the ticket.



来源:https://stackoverflow.com/questions/2237607/add-float-number-in-template-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!