in my sql table I have decimal data with dot as a separator but the display in my page is done with commas
I would like to display them with dot
in my settings i have this
LANGUAGE_CODE = "fr-fr"
TIME_ZONE = "UTC"
USE_I18N = True
USE_TZ = True
my models
class VilleStation(models.Model):
nomVille = models.CharField(max_length=255)
adresse = models.CharField(max_length=255)
cp = models.CharField(max_length=5)
latitude = models.DecimalField(max_digits=9, decimal_places=6)
longitude = models.DecimalField(max_digits=9, decimal_places=6)
in the templates i have this
{% for c in object_list %}
{{c.nomVille}}
{{c.adresse}}
{{c.cp}}
{{c.latitude}}
{{c.longitude}}
{% endfor %}
thank
2
Answers
Decimal separator is controlled by two settings in Django settings:
First one is DECIMAL_SEPARATOR (Default: ‘.’)
https://docs.djangoproject.com/en/4.1/ref/settings/#decimal-separator
And second one: USE_L10N (Default: True)
https://docs.djangoproject.com/en/4.1/ref/settings/#use-l10n
in your case use
USE_L10N=False
Give this a whirl, as per the docs, you can turn off number localisation like so:
What do the docs say?
Be aware of the following note further down the page:
And subsequently:
Please see the documentation regarding the floatformat template tag