Opened 5 years ago

Closed 5 years ago

#17542 closed Bug (fixed)

SelectDateWidget with required=false throws exception in _has_changed

Reported by: Owned by: pigletto
Component: Forms Version: 1.4-alpha-1
Severity: Normal Keywords: SelectDateWidget required false
Cc: restless.being@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When accessing changed_data in a form with SelectDateWidget with required=false and no values for year, month and date selected i get an exception.
The exception is thrown in strptime in

Code highlighting:

  def _has_changed(self, initial, data):
      input_format = get_format('DATE_INPUT_FORMATS')[0]
      data = datetime_safe.datetime.strptime(data, input_format).date()
      return super(SelectDateWidget, self)._has_changed(initial, data)  

because data is None

Attachments (1)

patch_for_17542.diff (1.8 KB) - added by pigletto 5 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 5 years ago by pigletto

  • Needs documentation unset
  • Needs tests set
  • Owner changed from nobody to pigletto
  • Patch needs improvement unset

comment:2 Changed 5 years ago by pigletto

  • Component changed from Uncategorized to Forms
  • Status changed from new to assigned

comment:3 Changed 5 years ago by pigletto

  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

Changed 5 years ago by pigletto

comment:4 Changed 5 years ago by pigletto

  • Has patch set

comment:5 Changed 5 years ago by ext

  • Cc restless.being@… added
  • Needs tests unset
  • Triage Stage changed from Accepted to Ready for checkin

Review done. It works.

comment:6 Changed 5 years ago by jezdez

  • Resolution set to fixed
  • Status changed from assigned to closed

In [17436]:

Fixed #17542 -- Gracefully handle errors when checking if the values of a SelectDateWidget has changed if it's not required. Thanks, pigletto.

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