Changes between Version 1 and Version 2 of Ticket #31595


Ignore:
Timestamp:
May 16, 2020, 3:10:35 AM (5 years ago)
Author:
Akshay Salunke
Comment:

Replying to akshaysalunke13:

So, I have a DateField in my model and have also set I18N & L10N to True in settings. When a browser running en-AU locale visits the website, Django tries to parse the value read from model, using the first value in DATE_INPUT_FORMATS from /conf.

The bug is when a user in en-AU locale visits the website, Django reads the Datefield value from model and tries to localize it for en-AU locale (from DATE_INPUT_FORMATS in /conf/en_AU) to this format '%d/%m/%Y', but html5 requires the value for <input type="date"> to be explicitly in this format: yyyy-MM-dd. [ref](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date) [ref2](https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats#Format_of_a_valid_date_string).

This causes an error in chrome dev console and the HTML date field rendered without the date read from the model.https://user-images.githubusercontent.com/2255284/82113682-326dc080-979b-11ea-8e7f-c442f30aae1f.png https://user-images.githubusercontent.com/2255284/82113676-2255e100-979b-11ea-973b-564fdb4a3497.png

This bug goes away when I disable L10N in settings. I am able to reproduce this bug in en-AU and en-GB

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31595 – Description

    v1 v2  
    11So, I have a DateField in my model and have also set **I18N & L10N** to `True`  in settings. When a browser running `en-AU` locale visits the website, Django tries to parse the value read from model, using the first value in `DATE_INPUT_FORMATS` from /conf.
    22
    3 The bug is when a user in `en-AU` locale visits the website, Django reads the Datefield value from model and tries to localize it for `en-AU` locale (from `DATE_INPUT_FORMATS` in /conf/en_AU) to this format `'%d/%m/%Y'`, but html5 requires the `value` for `<input type="date">` to be explicitly in this format: yyyy-MM-dd. [ref](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date) [ref2](https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats#Format_of_a_valid_date_string).
     3The bug is when a user in `en-AU` locale visits the website, Django reads the Datefield value from model and tries to localize it for `en-AU` locale (from `DATE_INPUT_FORMATS` in /conf/en_AU) to this format `'%d/%m/%Y'`, but html5 requires the `value` for `<input type="date">` to be explicitly in this format: yyyy-MM-dd. [[https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date| ref1]] [[https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats#Format_of_a_valid_date_string | ref2]]
    44
    55This causes an error in chrome dev console and the HTML date field rendered without the date read from the model.[[Image(https://user-images.githubusercontent.com/2255284/82113682-326dc080-979b-11ea-8e7f-c442f30aae1f.png)]]
Back to Top