Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#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


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 = {'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'} = {'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 Changed 5 years ago by Claude Paroz

Resolution: needsinfo
Status: newclosed

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?

comment:2 Changed 5 years ago by anonymous

Version: 1.61.5

My apologizes, I am using 1.5.

comment:3 Changed 5 years ago by Claude Paroz

Resolution: needsinfoworksforme

Feel free to reopen if you can reproduce it with a more recent version.

Note: See TracTickets for help on using tickets.
Back to Top