Opened 18 years ago
Closed 16 years ago
#3852 closed (duplicate)
[patch] newforms SelectDateWidget fails to display saved values correctly, lacks 'blank' choices
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | SelectDateWidget | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
SelectDateWidget in newforms.extras.widgets displays January 1, 2007 regardless of value entered.
render() assumes the value parameter is a string but it is being passed a datetime.date.
It sets the year, month, day to None before rendering the individual select tags.
This minimally invasive patch works for me but should be rewritten by someone with knowledge of how things are supposed to be - if value is supposed to be a datetime.date then that case should probably be handled in the "try" not the "except" as I've done.
Attachments (3)
Change History (9)
by , 18 years ago
Attachment: | newforms_extras_widgets.diff added |
---|
comment:1 by , 18 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 17 years ago
Attachment: | selectdatewidget_dashes.diff added |
---|
Adds initial 'dashes' choices at the top of the dropdowns, as with regular select fields
comment:2 by , 17 years ago
Sigh. Keep thinking the text field on the attachment page is going to be a file description instead of the comment body. This is what I really want to say:
I seem to be having this issue too. I don't have time right now to extensively investigate the issue, but I do want to be a parasite and attach my own diff to this ticket, for a very similar/related issue: if one wanted the fields to be blank, that's not possible at this point in time, as there are no dashes in the choice lists. My diff remedies this.
comment:3 by , 17 years ago
Summary: | [patch] newforms.extras.widgets SelectDateWidget shows January 1, (first year) → [patch] newforms SelectDateWidget fails to display saved values, has no blank options |
---|
comment:4 by , 17 years ago
Summary: | [patch] newforms SelectDateWidget fails to display saved values, has no blank options → [patch] newforms SelectDateWidget fails to display saved values correctly, lacks 'blank' choices |
---|
Apologies for ticket spam.
comment:5 by , 17 years ago
Here is a patch that does the coersion only when value is a basestring.
Otherwise, we just assume it's either a datetime.date or datetime.datetime object. If it isn't, it makes sense to throw an exception.
by , 17 years ago
Attachment: | django-selectdatewidget-datetime.patch added |
---|
Patch that only does coersion when value is a basestring.
comment:6 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
The issue of displaying saved values correctly was fixed by #5917
patch to fix newforms.extras.widgets.SelectDateWidget render() bug