Opened 6 years ago

Closed 5 years ago

#13437 closed Bug (invalid)

SelectDateField doesn't retain partially posted values when USE_L10N=True

Reported by: Russell Keith-Magee Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If you have localization enabled, and you have a SelectDateField (django.forms.extras.widgets), and you post a year, month and day value, the widget works as advertised.;

However, if you only post partial data (e.g., only the year and month, but *not* the day), the year and month value are not preserved; the widgets are reset to empty values.

This is inconsistent with the unlocalized behavior, which will preserve all available data.

This is because strftime can't format missing values, and strptime can't parse missing values. The parsing failure is turned into a None value for the entire date, rather than retaining partial data in a '2010-04-00' type structure as happens with unlocalized inputs.

Change History (3)

comment:1 Changed 6 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Related issue: #13339, which also requires a reimplementation of strptime to handle L10N edge cases.

comment:2 Changed 6 years ago by Julien Phalip

Severity: Normal
Type: Bug

comment:3 Changed 5 years ago by Claude Paroz

Easy pickings: unset
Resolution: invalid
Status: newclosed
UI/UX: unset

In current trunk, partially SelectDateWidget values are not retained, even with USE_L10N=False.

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