Code

Opened 4 years ago

Closed 2 years ago

#13437 closed Bug (invalid)

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

Reported by: russellm 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

Description

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.

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

comment:2 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:3 Changed 2 years ago by claudep

  • Easy pickings unset
  • Resolution set to invalid
  • Status changed from new to closed
  • UI/UX unset

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.