【发布时间】:2018-03-02 18:18:17
【问题描述】:
我在模板中使用了 total_prices
{{ data.total_prices }} # there shows 300
但是我怎样才能给它两个浮点数呢?
我的意思是它看起来像模板中的300.00。
如何处理?
【问题讨论】:
标签: python django django-templates
我在模板中使用了 total_prices
{{ data.total_prices }} # there shows 300
但是我怎样才能给它两个浮点数呢?
我的意思是它看起来像模板中的300.00。
如何处理?
【问题讨论】:
标签: python django django-templates
使用floatformat 模板过滤器,
{{ data.total_prices|floatformat:-2 }} # now it shows 300.00
【讨论】: