Python – Why django uses a comma as decimal separator

decimaldjangopython

I am using python 2.6 and django 1.27

my model

class Plan(models.Model):
     price = models.DecimalField(max_digits=5, decimal_places=2,default=0)
     .....

in my template i have

{{plan.price}}

My problem is that on my local machine i get dot used as separator for example '2.54'
While on my production machine i get '2,54' – comma is used as separator.
I would like it to use dot everywhere.

in the django docs
https://docs.djangoproject.com/en/1.2/ref/settings/#decimal-separator
it say there is the "DECIMAL_SEPARATOR" option the default it dot.

btw in both machines

In [2]: from django.conf import settings
In [3]: print settings.DECIMAL_SEPARATOR
.

SOLUTION:

as @Marcin pointed out
setting USE_L10N to False on production machine.

Best Answer

You can use this alternative way directly on your template:

{% load l10n %}

{% localize off %}
{{ my_floatvar }}
{% endlocalize %}

or this one:

{% load l10n %}

{{ my_floatvar|unlocalize }}

More info in https://docs.djangoproject.com/en/dev/topics/i18n/formatting/#controlling-localization-in-templates