如何获取十进制字段以在模板中显示更多小数位?

时间:2012-10-15 20:43:49

标签: django django-templates decimal

price_a = models.DecimalField(max_digits=5, decimal_places=3)

示例价格:95,90

在我的模板中:

{{ price_a }}

它只显示95,9。如何让它显示全价(额外的尾随0:95,90)?

1 个答案:

答案 0 :(得分:35)

使用floatformat模板过滤器,例如

{{ price_a|floatformat:2 }}