开发者

How to print number with commas as thousands separator and decimal places in Python/Django

I'm trying to display numbers in my Django templates with

  1. commas as thousand sepaerator and
  2. specifying the decimal places to round to.

e.g. 76384.8739439 -> 76,384.87

Django has template tags to achieve both these.

  • intcomma - for thousand separator and
  • floatformat - for decimal places

I can't seem to find a way to do both at the same time without writing m开发者_开发问答y own custom template filter. Anybody know of an easier solution?


{{ value|floatformat:2|intcomma }}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜