Format numbers in django templates

前端 未结 13 1157
清歌不尽
清歌不尽 2020-11-29 17:22

I\'m trying to format numbers. Examples:

1     => 1
12    => 12
123   => 123
1234  => 1,234
12345 => 12,345

It strikes as a

13条回答
  •  情深已故
    2020-11-29 18:17

    Be aware that changing locale is process-wide and not thread safe (iow., can have side effects or can affect other code executed within the same process).

    My proposition: check out the Babel package. Some means of integrating with Django templates are available.

提交回复
热议问题