diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 177ae57f24..b1c612c26a 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -8,7 +8,6 @@ import warnings from collections import defaultdict from itertools import chain -from django.conf import settings from django.forms.utils import to_current_timezone from django.templatetags.static import static from django.utils import datetime_safe, formats @@ -1028,7 +1027,7 @@ class SelectDateWidget(Widget): # Convert any zeros in the date to empty strings to match the # empty option value. year, month, day = [int(val) or '' for val in match.groups()] - elif settings.USE_L10N: + else: input_format = get_format('DATE_INPUT_FORMATS')[0] try: d = datetime.datetime.strptime(value, input_format) diff --git a/tests/forms_tests/widget_tests/test_selectdatewidget.py b/tests/forms_tests/widget_tests/test_selectdatewidget.py index ea1c31b487..00cfbae758 100644 --- a/tests/forms_tests/widget_tests/test_selectdatewidget.py +++ b/tests/forms_tests/widget_tests/test_selectdatewidget.py @@ -487,7 +487,7 @@ class SelectDateWidgetTest(WidgetTest): @override_settings(USE_L10N=False, DATE_INPUT_FORMATS=['%d.%m.%Y']) def test_custom_input_format(self): w = SelectDateWidget(years=('0001', '1899', '2009', '2010')) - for values, expected in ( + for values, expected_value in ( (('0001', '8', '13'), '13.08.0001'), (('1899', '7', '11'), '11.07.1899'), (('2009', '3', '7'), '07.03.2009'), @@ -497,7 +497,12 @@ class SelectDateWidgetTest(WidgetTest): 'field_%s' % field: value for field, value in zip(('year', 'month', 'day'), values) } - self.assertEqual(w.value_from_datadict(data, {}, 'field'), expected) + self.assertEqual(w.value_from_datadict(data, {}, 'field'), expected_value) + expected_dict = { + field: int(value) + for field, value in zip(('year', 'month', 'day'), values) + } + self.assertEqual(w.format_value(expected_value), expected_dict) def test_format_value(self): valid_formats = [