diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py index 4dabafae9e..7d05942f43 100644 --- a/django/forms/extras/widgets.py +++ b/django/forms/extras/widgets.py @@ -7,6 +7,7 @@ import datetime import re from django.forms.widgets import Widget, Select +from django.utils import datetime_safe from django.utils.dates import MONTHS from django.utils.safestring import mark_safe from django.utils.formats import get_format @@ -100,6 +101,7 @@ class SelectDateWidget(Widget): except ValueError: pass else: + date_value = datetime_safe.new_date(date_value) return date_value.strftime(input_format) else: return '%s-%s-%s' % (y, m, d) diff --git a/tests/regressiontests/forms/extra.py b/tests/regressiontests/forms/extra.py index 7547901d0f..57e8e91a60 100644 --- a/tests/regressiontests/forms/extra.py +++ b/tests/regressiontests/forms/extra.py @@ -435,6 +435,11 @@ USE_L10N tests +Years before 1900 work +>>> w = SelectDateWidget(years=('1899',)) +>>> w.value_from_datadict({'date_year': '1899', 'date_month': '8', 'date_day': '13'}, {}, 'date') +'13-08-1899' + >>> translation.deactivate() # MultiWidget and MultiValueField #############################################