summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorGuillaume Pannatier <guillaume.pannatier@gmail.com>2014-05-23 09:07:15 +0200
committerTim Graham <timograham@gmail.com>2014-05-28 13:23:28 -0400
commit32586b0ba43816d325be0ce807f75623683eed7a (patch)
tree7aee8f593e816351b9ae4be11f74105f6eb797a9 /django/forms
parentfd427f1fe3c563d5fe0badfec0a39d6cd43454da (diff)
Fixed #22684 -- Added `empty_label` option on `django.forms.extras.widets.SelectDateWidget`
Thanks danielsamuels for the report
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/extras/widgets.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py
index ea26cbe4e4..09d22b0fb5 100644
--- a/django/forms/extras/widgets.py
+++ b/django/forms/extras/widgets.py
@@ -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