0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

Fixed #27724 -- Fixed SelectDateWidget redisplay if a year isn't chosen.

This commit is contained in:
Adonys Alea Boffill 2017-03-17 16:02:07 -04:00 committed by Tim Graham
parent fb48ad348a
commit cd2ad26cc9
2 changed files with 2 additions and 1 deletions

View File

@ -894,7 +894,7 @@ class SelectDateWidget(Widget):
template_name = 'django/forms/widgets/select_date.html'
input_type = 'select'
select_widget = Select
date_re = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$')
date_re = re.compile(r'(\d{4}|0)-(\d\d?)-(\d\d?)$')
def __init__(self, attrs=None, years=None, months=None, empty_label=None):
self.attrs = attrs or {}

View File

@ -482,6 +482,7 @@ class SelectDateWidgetTest(WidgetTest):
valid_formats = [
'2000-1-1', '2000-10-15', '2000-01-01',
'2000-01-0', '2000-0-01', '2000-0-0',
'0-01-01', '0-01-0', '0-0-01', '0-0-0',
]
for value in valid_formats:
year, month, day = (int(x) for x in value.split('-'))