I've searched several threads and bug reports, but couldn't find a solution.
I changed the locale of my Django project to pt-br
but it made no difference. I excepted all input fields and outputs to localize dates and numbers, specially DECIMAL_SEPARATOR
and THOUSAND_SEPARATOR
, including in the admin API. But the dates there continue to appear as yyyy-mm-dd
and decimal separator "," generates an error upon input.
I did everything I found: changed the settings, added localization middleware classes, enabled USE_I18N and USE_L10N, tried to force setlocale manually, etc. Here is a glimpse of my settings.py:
LANGUAGE_CODE = 'pt-br'
USE_I18N = True
USE_L10N = True
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)
DATE_FORMAT = 'd/m/Y'
SHORT_DATE_FORMAT = 'd/m/Y'
DATE_INPUT_FORMATS = ('%d/%m/%Y', '%d/%m/%y', '%Y-%m-%d')
DECIMAL_SEPARATOR = ','
THOUSAND_SEPARATOR = '.'
Is it weird that my Python console running on a Brazilian Portuguese Windows outputs this?
>>> locale.setlocale(locale.LC_ALL, ('pt_BR', 'cp1252'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\lib\locale.py", line 478, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
Any ideas of what I forgot to try?