[Django] #21556: Date field shows in changed_data due to different format

20 views
Skip to first unread message

Django

unread,
Dec 3, 2013, 6:14:44 PM12/3/13
to django-...@googlegroups.com
#21556: Date field shows in changed_data due to different format
----------------------------+--------------------
Reporter: anonymous | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/21556>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 4, 2013, 8:47:56 AM12/4/13
to django-...@googlegroups.com
#21556: Date field shows in changed_data due to different format
---------------------------+--------------------------------------
Reporter: anonymous | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.6
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------
Changes (by claudep):

* status: new => closed
* needs_better_patch: => 0
* resolution: => needsinfo
* needs_tests: => 0
* needs_docs: => 0


Comment:

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?

--
Ticket URL: <https://code.djangoproject.com/ticket/21556#comment:1>

Django

unread,
Dec 4, 2013, 10:00:36 PM12/4/13
to django-...@googlegroups.com
#21556: Date field shows in changed_data due to different format
---------------------------+--------------------------------------
Reporter: anonymous | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.5
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------
Changes (by anonymous):

* version: 1.6 => 1.5


Comment:

My apologizes, I am using 1.5.

--
Ticket URL: <https://code.djangoproject.com/ticket/21556#comment:2>

Django

unread,
Dec 5, 2013, 3:24:00 AM12/5/13
to django-...@googlegroups.com
#21556: Date field shows in changed_data due to different format
---------------------------+--------------------------------------
Reporter: anonymous | Owner: nobody

Type: Bug | Status: closed
Component: Forms | Version: 1.5
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------
Changes (by claudep):

* resolution: needsinfo => worksforme


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/21556#comment:3>

Reply all
Reply to author
Forward
0 new messages