Opened 22 months ago

Closed 22 months ago

Last modified 22 months 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 22 months ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

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 22 months ago by anonymous

  • Version changed from 1.6 to 1.5

My apologizes, I am using 1.5.

comment:3 Changed 22 months ago by claudep

  • Resolution changed from needsinfo to worksforme

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