Opened 16 years ago

Last modified 14 years ago

#6783 closed

DecimalField python locale issue — at Initial Version

Reported by: Dirk Datzert <dummy@…> Owned by: nobody
Component: Internationalization Version: dev
Severity: Keywords: i18n-fixed
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I ran into an python locale issue with the DecimalField. During INSERTs and UPDATEs invalid sql-statements are generated since a comma-seperator ',' is used for formating DecimalField instead of the expected dot-seperator '.'

decimal-python.py (for simple testing):
from django.db.models.fields import DecimalField
from locale import setlocale, LC_NUMERIC
d = DecimalField(max_digits=6, decimal_places=3)
setlocale(LC_NUMERIC,'de_DE')
print d.format_number(3.456)
setlocale(LC_NUMERIC,'en_US')
print d.format_number(3.456)


linux-f426d:/home/admin/django/projects # export DJANGO_SETTINGS_MODULE=ais.settings
linux-f426d:/home/admin/django/projects # python decimal-python.py
3,456
3.456

Environment: Django-SVN
SuSE Linux Enterprise Server 10
Python 2.4.2

On my private notebook this is no issue both outputs will be
3.456
3.456
Private Environment: Django-SVN
OpenSuSe 10.3
Python 2.5.1

Change History (3)

by Dirk Datzert <dummy@…>, 16 years ago

short work-around for DecimalField format problems in db_prep methods

by Dirk Datzert <dummy@…>, 16 years ago

short work-around for DecimalField format problems in db_prep methods

by Philippe Raoult, 16 years ago

Attachment: 6783_tests.diff added

base tests for the issue

Note: See TracTickets for help on using tickets.
Back to Top