开发者

add float number in template (django)

开发者 https://www.devze.com 2022-12-19 23:16 出处:网络
Maybe i\'m missing something but i\'m looking to add a float number, something like this: {%floatnumber|add:3.4%}

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

{%floatnumber|add:3.4%}

Filter add roun开发者_StackOverflowd 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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号