Hi,

Forget currency

How I inset comma in:

{{ total_in|floatformat:2 }}

to get : 32,525.75 for example

Thanks,

Shay Ben Dov


On Dec 26, 8:45 am, Alexander Kojevnikov <alexan...@kojevnikov.com>
wrote:
> Shay, you can try this code:
>
> import locale
> from django import template
>
> register = template.Library()
>
> @register.filter()
> def currency(value):
>     locale.setlocale(locale.LC_ALL, '')
>     return locale.currency(value, grouping=True)
>
> Also, in your template you should add this line near the top:
>
> {% load filters %}
>
> Let me know if this doesn't work.
>
> Cheers,
> Alex
> --www.muspy.com
>
> On Dec 26, 5:35 pm,ShayBen Dov <shay.ben...@gmail.com> wrote:
>
> > Alex Hi,
>
> > if I want to use something like:
>
> > {{money|local}}
>
> > where do I put your input about import locale
>
> > because I saw this snippet
>
> > from django import template
> > import locale
> > locale.setlocale(locale.LC_ALL, '')
> > register = template.Library()
>
> > @register.filter()
> > def currency(value):
> >     return locale.currency(value, grouping=True)
>
> > and it doesn't work.
>
> > I'm new to GAE stuff and it seems to me a lot of trouble to format for
> > currency.
>
> > we should have a filter like {{sum|currency}} where we can change the
> > currency symbol like it is done in other languages.
>
> > or in short how I use you tip.
>
> > Happy New Year
>
> >Shay
>
> > On Dec 25, 12:49 am, Alexander Kojevnikov <alexan...@kojevnikov.com>
> > wrote:
>
> > > You can also use the standard locale module:
>
> > > >>> import locale
> > > >>> locale.setlocale(locale.LC_ALL, '')
> > > >>> locale.format('%.2f', 1234.5678, True)
>
> > > '1,234.57'
>
> > >http://www.python.org/doc/2.5.2/lib/module-locale.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to