diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py
index 4fb4869..a66b759 100644
a
|
b
|
class SelectDateWidget(Widget):
|
136 | 136 | return select_html |
137 | 137 | |
138 | 138 | def _has_changed(self, initial, data): |
139 | | input_format = get_format('DATE_INPUT_FORMATS')[0] |
140 | | data = datetime_safe.datetime.strptime(data, input_format).date() |
| 139 | try: |
| 140 | input_format = get_format('DATE_INPUT_FORMATS')[0] |
| 141 | data = datetime_safe.datetime.strptime(data, input_format).date() |
| 142 | except (TypeError, ValueError): |
| 143 | pass |
141 | 144 | return super(SelectDateWidget, self)._has_changed(initial, data) |
| 145 | No newline at end of file |
diff --git a/tests/regressiontests/forms/tests/extra.py b/tests/regressiontests/forms/tests/extra.py
index 3c5dfab..c873af7 100644
a
|
b
|
from .error_messages import AssertFormErrorsMixin
|
18 | 18 | class GetDate(Form): |
19 | 19 | mydate = DateField(widget=SelectDateWidget) |
20 | 20 | |
| 21 | class GetNotRequiredDate(Form): |
| 22 | mydate = DateField(widget=SelectDateWidget, required=False) |
| 23 | |
21 | 24 | class GetDateShowHiddenInitial(Form): |
22 | 25 | mydate = DateField(widget=SelectDateWidget, show_hidden_initial=True) |
23 | 26 | |
… |
… |
class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
|
619 | 622 | self.assertTrue(FormWithFile().is_multipart()) |
620 | 623 | self.assertTrue(FormWithImage().is_multipart()) |
621 | 624 | |
| 625 | def test_field_not_required(self): |
| 626 | b = GetNotRequiredDate({ |
| 627 | 'mydate_year': '', |
| 628 | 'mydate_month': '', |
| 629 | 'mydate_day': '' |
| 630 | }) |
| 631 | self.assertFalse(b.has_changed()) |
| 632 | |
| 633 | |
622 | 634 | |
623 | 635 | class FormsExtraL10NTestCase(TestCase): |
624 | 636 | def setUp(self): |