Django将数千个模板分开 [英] Django separate thousands in template

查看:105
本文介绍了Django将数千个模板分开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的模型正在返回一个十进制(1234567.50),我似乎不能用千位分隔符显示十进制。 Django有没有办法做到这一点?我需要创建自己的模板过滤器吗?

My model is returning a Decimal(1234567.50), I can't seem to display the Decimal with a thousands separator. Does Django have a way to do this? Do I need to create my own template filter?

谢谢。

推荐答案

p>您可以使用 intcomma 过滤器,但是我不认为它将在十进制对象上工作,它适用于十进制对象。你必须先转换成float / string。

You can use the intcomma filter, but I don't think it will work on Decimal objects and it works on Decimal objects. You'll have to convert to float/string first.

这篇关于Django将数千个模板分开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆