0

I want to read a localized greek date for my django project. The correct format for greek dates is dd/mm/yy (f.e. 22/2/2012).

Now, I have set my project language (in settings.py) to 'el' (for greek) and I have create a DateInput with localize=True. If I try to enter a dd/mm/yy format I get an error (invalid format) response. On the other hand if I try to enter a mm/dd/yy format it works fine. Also, if I change my project language from 'el' to 'en-GB' (for UK english), the dd/mm/yy format is accepted successfully.

Before going crazy, I took a look at the django source code and more specifically to the file:

https://github.com/django/django/blob/master/django/conf/locale/el/formats.py

which should contain the formats for greece but foun out that the DATE_INPUT_FORMATS was commented out. On the other hand, the same file for UK English (https://github.com/django/django/blob/master/django/conf/locale/en_GB/formats.py) contained two valid entries for DATE_INPUT_FORMATS. Could that be related to the problem ?

I know that I can set the widget format (like described in this question Making Django forms.DateField show use local date format) however I'd really like to use the L10N capabilities and not add different date formats for each language I want to support :(

Community
  • 1
  • 1
Serafeim
  • 14,962
  • 14
  • 91
  • 133
  • `"%x"` will give you the locale defined format string ... but you then have to make sure you actually set the locale ... – Joran Beasley Feb 17 '14 at 21:59
  • I have a normal django form with a normal dateinput. I want to be able to read a date in the 22/02/2012 format without getting a validation error. Where would "%x" help me ? – Serafeim Feb 17 '14 at 22:01

0 Answers0