Opened 8 years ago
Closed 8 years ago
#28090 closed Bug (duplicate)
TimeField's value incorrectly localized in forms — at Version 2
Reported by: | Tomek Rej | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | ygan@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When passing a datetime.time
instance to the choices parameter in a TimeField
, the admin template converts it to a human readable form. For example, time(0, 0)
is converted to "midnight", time(1, 30)
is converted to 1:30 a.m. In Django 1.10, it gets formatted as 00:00:00 and 01:30:00 respectively.
An example of the choices I pass in to the constructor is:
[ (datetime.time(0, 0), '00:00'), (datetime.time(0, 30), '00:30'), (datetime.time(1, 0), '01:00'), ...., (datetime.time(23, 30), '23:30') ]
This causes the admin form validation to fail with errors like the following:
Select a valid choice. midnight is not one of the available choices.
Change History (2)
comment:1 by , 8 years ago
Cc: | added |
---|
comment:2 by , 8 years ago
Component: | Uncategorized → Forms |
---|---|
Description: | modified (diff) |
Resolution: | → duplicate |
Status: | new → closed |
Summary: | TimeField rendering in admin forms → TimeField's value incorrectly localized in forms |
Triage Stage: | Unreviewed → Accepted |
Bisected to 6d8979f4c2fbfb9fd5db92acd72489cbbcbdd5d1. It happens in forms outside the admin also. I think it's a duplicate of #28075 -- the
<select>
value
is inadvertently localized just like in that ticket.