31 django numbers decimal rounding
我想舍入我的小数值如下:
7,715.625变为7,716
我该如何实现这一目标?
Dom*_*ger 68
如果你不关心逗号,那么floatformat就可以完成这项工作:
floatformat
{{ value|floatformat:"0" }}
如果你关心逗号,你想要:
{{ value|floatformat:"0"|intcomma }}
(帽子小费让斯蒂芬指着我intcomma!)
intcomma
小智 9
要使用intcomma过滤器,您应该添加django.contrib.humanize到您的INSTALLED_APPS设置和{% load humanize %}模板中.
django.contrib.humanize
INSTALLED_APPS
{% load humanize %}
归档时间:
17 年,2 月 前
查看次数:
23907 次
最近记录:
9 年,9 月 前