#21556 closed Bug (worksforme)
Date field shows in changed_data due to different format
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
For a form, DateField can accept multiple formats, e.g. I can set
form['mydate'].input_formats = ('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y')
And if I post
form.data = {'mydate': '01/15/2013'}
The form will happily accepts the format.
However, if the date did not really change:
form.initial = {'mydate': '2013-01-15'} form.data = {'mydate': '01/15/2013'}
'mydate' will show up in form.changed_data, because widgets.DateInput._format_value can only use one format, there's no way to make the widget recognize multiple formats.
Change History (3)
comment:1 by , 11 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:3 by , 11 years ago
Resolution: | needsinfo → worksforme |
---|
Feel free to reopen if you can reproduce it with a more recent version.
Note:
See TracTickets
for help on using tickets.
Are you really using Django 1.6? Some recent improvements have been made in this realm. Change detection is now done on the field level and the input value is transformed to a python date value before the comparison, so generally what you describe should not happen.
Could you please give us a more comprehensive code example so as we can better see what's happening in your case?