Quick and nasty:
from django.core import template
register = template.Library()
@register.filter(name='commas')
def commas(value):
return "".join(commafy(value))
def commafy(s):
pieces = s.split(".")
l = len(pieces[0])
for i in range(0,l):
if (l -
Rock wrote:
> Is there a template filter for turning a large integer into a human
> readable number?
>
> 1234567 --> 1,234,567
> 12345 --> 12,345
>
> I don't think that python built-in formatting can do this. (Am I
> wrong?)
>
> Assuming there isn't already a simple filter that will do this,
On Friday 24 March 2006 12:23, Jacob Kaplan-Moss wrote:
> > I don't think that python built-in formatting can do this. (Am I
> > wrong?)
>
> Actually, locale.format will do it for you, IIRC.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'en_US.UTF-8'
>>> locale.format("%d", 1234567, T
On Mar 24, 2006, at 1:48 PM, Rock wrote:
> Is there a template filter for turning a large integer into a human
> readable number?
>
> 1234567 --> 1,234,567
> 12345 --> 12,345
>
> I don't think that python built-in formatting can do this. (Am I
> wrong?)
Actually, locale.format will do it for yo
Is there a template filter for turning a large integer into a human
readable number?
1234567 --> 1,234,567
12345 --> 12,345
I don't think that python built-in formatting can do this. (Am I
wrong?)
Assuming there isn't already a simple filter that will do this, what do
I need to learn about in
5 matches
Mail list logo