Use of L10N forces date formats for input and prevents to use other formats
We use L10N to display date, times and numbers using locale preferences (correct date formats, decimal separator, ...). But Django also consider the format specified by L10N as an input validator. Meaning in English local we can't use the format dd/mm/yyyy
but we are force to use dd-mm-yyyy
which is bullshit !! (And in FR we are force to keep the dd/mm/yyyy
formqt) I haven't tested but this should also force you to use a point instead of a comma as a decimal separator ....
Possibilities to solve this:
- Remove
USE_L10N
settings. It's working at least, everything is using the default english format (which meansdd-mm-yyyy
but alsoMonth, nth year
) which is not very nice to French people. We can enforce the display only to use L10N with templatetags (https://docs.djangoproject.com/en/2.0/topics/i18n/formatting/#controlling-localization-in-templates). But inputs will still need to use the default english format (and we will need to change the help texts of those input to use-
instead of/
). So this means you have a (visual) difference between what you inputs and what you see in the results. - We can specify localized formats (https://docs.djangoproject.com/en/2.0/topics/i18n/formatting/#creating-custom-format-files) to force every language to use the same format (but this require to write the same file for every supported languages which is painful). Which leads to the same problem as removing the
USE_L10N
setting : everybody has the same display and inputs and it means some people using other locales will be desoriented by the forced format. At least we can now choose something different than the english format as default. Unfortunately we cannot use anymore the templatetags to display different formats (because we forced them to be the same in every language) - Keep everything as it is but use a different help_text on inputs to adapt the localized format to use. This solution litterally means using the translation on the
help_text
so this is related to #36 (closed) . - Force the input field to accept any "common" format. I don't know how to do that. This is probably an option of datetime.datetime that we have to pass somehow through the Django.DateTimeField options