diff --git a/django/forms/widgets.py b/django/forms/widgets.py index f306abdec6..35904d3372 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -958,7 +958,7 @@ class SelectDateWidget(Widget): def get_context(self, name, value, attrs): context = super().get_context(name, value, attrs) date_context = {} - year_choices = [(i, i) for i in self.years] + year_choices = [(i, str(i)) for i in self.years] if not self.is_required: year_choices.insert(0, self.year_none_value) year_attrs = context['widget']['attrs'].copy() diff --git a/docs/releases/1.11.5.txt b/docs/releases/1.11.5.txt index 5716ad63c1..92fa8820a0 100644 --- a/docs/releases/1.11.5.txt +++ b/docs/releases/1.11.5.txt @@ -29,3 +29,6 @@ Bugfixes * Omitted ``pages_per_range`` from ``BrinIndex.deconstruct()`` if it's ``None`` (:ticket:`25809`). + +* Fixed a regression where ``SelectDateWidget`` localized the years in the + select box (:ticket:`28530`). diff --git a/tests/forms_tests/widget_tests/test_selectdatewidget.py b/tests/forms_tests/widget_tests/test_selectdatewidget.py index 9cc646a67a..83e76069b6 100644 --- a/tests/forms_tests/widget_tests/test_selectdatewidget.py +++ b/tests/forms_tests/widget_tests/test_selectdatewidget.py @@ -504,3 +504,64 @@ class SelectDateWidgetTest(WidgetTest): self.assertIs(self.widget.value_omitted_from_data({'field_day': '1'}, {}, 'field'), False) data = {'field_day': '1', 'field_month': '12', 'field_year': '2000'} self.assertIs(self.widget.value_omitted_from_data(data, {}, 'field'), False) + + @override_settings(USE_THOUSAND_SEPARATOR=True, USE_L10N=True) + def test_years_rendered_without_separator(self): + widget = SelectDateWidget(years=(2007,)) + self.check_html(widget, 'mydate', '', html=( + """ + + + + """ + ))