[google-appengine] Re: Money sum formating

2008-12-28 Thread Shay Ben Dov

Hi,

I tried what you suggested and this is what I got:

type 'exceptions.EnvironmentError': Environment variable
DJANGO_SETTINGS_MODULE is undefined.
  args = ('Environment variable DJANGO_SETTINGS_MODULE is
undefined.',)
  errno = None
  filename = None
  message = 'Environment variable DJANGO_SETTINGS_MODULE is
undefined.'
  strerror = None

Every help is necessary.

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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-28 Thread Shay Ben Dov

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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-28 Thread Alexander Kojevnikov

Which version of Django do you use? Could you also post the full stack
trace?

On Dec 29, 5:24 am, Shay Ben Dov shay.ben...@gmail.com wrote:
 Hi,

 I tried what you suggested and this is what I got:

 type 'exceptions.EnvironmentError': Environment variable
 DJANGO_SETTINGS_MODULE is undefined.
       args = ('Environment variable DJANGO_SETTINGS_MODULE is
 undefined.',)
       errno = None
       filename = None
       message = 'Environment variable DJANGO_SETTINGS_MODULE is
 undefined.'
       strerror = None

 Every help is necessary.

 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-28 Thread Alexander Kojevnikov

 Forget currency

 How I inset comma in:

 {{ total_in|floatformat:2 }}

 to get : 32,525.75 for example

You can use this filter:

@register.filter()
def comma(value):
locale.setlocale(locale.LC_ALL, '')
return locale.format('%.2f', 1234.5678, True)

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-25 Thread Shay Ben Dov

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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-25 Thread Alexander Kojevnikov

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, Shay Ben 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-24 Thread Joel Odom
Here's a little function I wrote that you may have:

def formatAsDollars(amount):
  dollars = int(amount)
  cents = amount - dollars

  i = 0
  reverseDollarPlaces = []
  for p in str(dollars)[::-1]:
if i % 3 == 0 and i:
  reverseDollarPlaces.append(',')
reverseDollarPlaces.append(p)
i += 1

  return '$%s.%.2i' % (''.join(reverseDollarPlaces[::-1]), int(100*cents))




On Tue, Dec 23, 2008 at 2:32 PM, Shay Ben Dov shay.ben...@gmail.com wrote:


 Hi,

 I know that if

 sum = 56.0

 then

 {{ sum|floatformat:2 }} will display 56.00

 How we get $560,000.00

 Thanks,

 Shay Ben Dov



 



-- 
http://giscoder.blogspot.com/

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-24 Thread djidjadji

The next function is a bit faster

import re
def formatAsDollars(amount):
  part = (%.2f%amount).split(.)
  part[0] = re.sub(r'\B(?=(...)*$)',',',part[0])
  return '$'+'.'.join(part)


2008/12/24 Joel Odom joelo...@gmail.com:
 Here's a little function I wrote that you may have:

 def formatAsDollars(amount):
   dollars = int(amount)
   cents = amount - dollars

   i = 0
   reverseDollarPlaces = []
   for p in str(dollars)[::-1]:
 if i % 3 == 0 and i:
   reverseDollarPlaces.append(',')
 reverseDollarPlaces.append(p)
 i += 1

   return '$%s.%.2i' % (''.join(reverseDollarPlaces[::-1]), int(100*cents))

 On Tue, Dec 23, 2008 at 2:32 PM, Shay Ben Dov shay.ben...@gmail.com wrote:

 Hi,

 I know that if

 sum = 56.0

 then

 {{ sum|floatformat:2 }} will display 56.00

 How we get $560,000.00

 Thanks,

 Shay Ben Dov
 --
 http://giscoder.blogspot.com/

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-24 Thread Alexander Kojevnikov

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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-24 Thread Shay Ben Dov

Thanks for the answer.

Merry Christmas  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
-~--~~~~--~~--~--~---



[google-appengine] Re: Money sum formating

2008-12-23 Thread djidjadji

Have a look at
google_appengine/lib/django/django/template/defaultfilters.py
it contains the implementation of the default django 0.96 filters.
Just write your own and add it to the Library().
That should be possible from your own python file.

2008/12/23 Shay Ben Dov shay.ben...@gmail.com:

 Hi,

 I know that if

 sum = 56.0

 then

 {{ sum|floatformat:2 }} will display 56.00

 How we get $560,000.00

 Thanks,

 Shay Ben Dov



 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---