Open swiss-knight opened 8 months ago
Hello,
I have the same problem.
All but hard coding the locale and format in each DatePickerInput
's widget options fails.
It seems, at least in my case, that datepicker-plus somehow fetches the global options from the server it is running on:
$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME=C
instead of the settings in settings.py
:
LANGUAGE_CODE = 'de-DE'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
...
BOOTSTRAP_DATEPICKER_PLUS = {
"options": {
"locale": "de-DE",
},
"variant_options": {
"date": {
"format": "DD.MM.YYYY",
},
},
}
For reference, my setup information:
Hello,
I'm using a
DatePickerInput()
widget in a form in order to let a user select a date using this nice calendar widget within a django 4.2 application.The locale is set as follow in the
settings.py
file:The form is as follow:
And the corresponding app model is:
The widget looks as follow when it's set to the 9th of January 2024:
But it should be
09.01.2024
because the browser language is set to French. And when I watch at what is stored in the db, it's written2024-09-01
(1st September 2024).So I have to hard code that in the widget options in
MyForm()
class:(There is no fancy templating:
and nothing special in the
views
)Then it works within a French browser environment.
But now, when browsing the app using an English browser, the widget stays as it is coded (this is normal I guess):
and the user can no more submit the form because of a server error:
Expected behavior So I would like to know if it's possible to make the
DatePickerInput()
widget be aware of the locale? (Same goes for theDateTimePickerInput()
widget).If yes, how precisely?
For the moment, I'm thinking it's a bug or a missing feature.
Thanks a lot!
Setup Information (please complete the following information):
[x] I have followed the configuration instructions and checked out the common error troubleshooting page.