1
0
mirror of https://github.com/django/django.git synced 2025-10-30 00:56:09 +00:00

Fixed #22684 -- Added empty_label option on django.forms.extras.widets.SelectDateWidget

Thanks danielsamuels for the report
This commit is contained in:
Guillaume Pannatier
2014-05-23 09:07:15 +02:00
committed by Tim Graham
parent fd427f1fe3
commit 32586b0ba4
5 changed files with 26 additions and 1 deletions

View File

@@ -48,7 +48,7 @@ class SelectDateWidget(Widget):
day_field = '%s_day'
year_field = '%s_year'
def __init__(self, attrs=None, years=None, months=None):
def __init__(self, attrs=None, years=None, months=None, empty_label=None):
self.attrs = attrs or {}
# Optional list or tuple of years to use in the "year" select box.
@@ -64,6 +64,9 @@ class SelectDateWidget(Widget):
else:
self.months = MONTHS
if empty_label is not None:
self.none_value = (0, empty_label)
def render(self, name, value, attrs=None):
try:
year_val, month_val, day_val = value.year, value.month, value.day