1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

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

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17436 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel
2012-02-04 16:05:58 +00:00
parent e734477bd7
commit 56d787df99
2 changed files with 18 additions and 3 deletions

View File

@@ -136,6 +136,9 @@ class SelectDateWidget(Widget):
return select_html
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)
try:
input_format = get_format('DATE_INPUT_FORMATS')[0]
data = datetime_safe.datetime.strptime(data, input_format).date()
except (TypeError, ValueError):
pass
return super(SelectDateWidget, self)._has_changed(initial, data)