#18777 closed Bug (fixed)
Visualization of date fields as_hidden aren't localized
Reported by: | César H. Roldán | Owned by: | Aleksandra Sendecka |
---|---|---|---|
Component: | Forms | Version: | 1.4 |
Severity: | Normal | Keywords: | date widget hidden sprint2013 |
Cc: | asendecka@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When use a date field as_hidden in template, the value isn't localized.
For example, in my settings.py I set:
LANGUAGE_CODE="es_ar"
and when I use:
{{form.field.as_hidden}}
I recieve:
<input type="hidden" name="date_field" value="2012-01-01" id="id_date_field">
and the correct format must be:
<input type="hidden" name="date_field" value="01/01/2012" id="id_date_field">
The Input widget does not use format for those types (see Date, DateTime or Time widgets)
Attachments (1)
Change History (9)
by , 12 years ago
Attachment: | django_date_time_hidden.patch added |
---|
comment:1 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 12 years ago
Cc: | added |
---|---|
Keywords: | sprint2013 added |
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 12 years ago
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
The problem here is much deeper. The same behavior is for any field that had to be localized (for example decimal field). It turned out that if we call functions such as as_hidden or as_text on a field, the value will not be localized. The fix is on the Field level: prepare_value method checks if the widget has 'is_localized' set to True and if so, runs formats.localize_input(value).
The patch is here:
https://github.com/django/django/pull/825