Format numbers in django templates

I’m trying to format numbers. Examples:

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

It strikes as a fairly common thing to do but I can’t figure out which filter I’m supposed to use.

Edit: If you’ve a generic Python way to do this, I’m happy adding a formatted field in my model.

13 Answers
13

Leave a Comment