Opened 8 years ago

Closed 8 years ago

#17542 closed Bug (fixed)

SelectDateWidget with required=false throws exception in _has_changed

Reported by: Owned by: Maciej Wiśniowski
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 Maciej Wiśniowski 8 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by Maciej Wiśniowski

Needs tests: set
Owner: changed from nobody to Maciej Wiśniowski

comment:2 Changed 8 years ago by Maciej Wiśniowski

Component: UncategorizedForms
Status: newassigned

comment:3 Changed 8 years ago by Maciej Wiśniowski

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

Changed 8 years ago by Maciej Wiśniowski

Attachment: patch_for_17542.diff added

comment:4 Changed 8 years ago by Maciej Wiśniowski

Has patch: set

comment:5 Changed 8 years ago by Jakub Wiśniowski

Cc: restless.being@… added
Needs tests: unset
Triage Stage: AcceptedReady for checkin

Review done. It works.

comment:6 Changed 8 years ago by Jannis Leidel

Resolution: fixed
Status: assignedclosed

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