diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 76c12e2..ded6538 100644
a
|
b
|
class SelectDateWidget(Widget):
|
911 | 911 | This also serves as an example of a Widget that has more than one HTML |
912 | 912 | element and hence implements value_from_datadict. |
913 | 913 | """ |
914 | | none_value = (0, '---') |
| 914 | none_value = ('', '---') |
915 | 915 | month_field = '%s_month' |
916 | 916 | day_field = '%s_day' |
917 | 917 | year_field = '%s_year' |
… |
… |
class SelectDateWidget(Widget):
|
941 | 941 | if not len(empty_label) == 3: |
942 | 942 | raise ValueError('empty_label list/tuple must have 3 elements.') |
943 | 943 | |
944 | | self.year_none_value = (0, empty_label[0]) |
945 | | self.month_none_value = (0, empty_label[1]) |
946 | | self.day_none_value = (0, empty_label[2]) |
| 944 | self.year_none_value = ('', empty_label[0]) |
| 945 | self.month_none_value = ('', empty_label[1]) |
| 946 | self.day_none_value = ('', empty_label[2]) |
947 | 947 | else: |
948 | 948 | if empty_label is not None: |
949 | | self.none_value = (0, empty_label) |
| 949 | self.none_value = ('', empty_label) |
950 | 950 | |
951 | 951 | self.year_none_value = self.none_value |
952 | 952 | self.month_none_value = self.none_value |
diff --git a/tests/forms_tests/widget_tests/test_selectdatewidget.py b/tests/forms_tests/widget_tests/test_selectdatewidget.py
index 83e7606..3b99e9e 100644
a
|
b
|
class SelectDateWidgetTest(WidgetTest):
|
18 | 18 | self.check_html(self.widget, 'mydate', '', html=( |
19 | 19 | """ |
20 | 20 | <select name="mydate_month" id="id_mydate_month"> |
21 | | <option value="0">---</option> |
| 21 | <option selected value="">---</option> |
22 | 22 | <option value="1">January</option> |
23 | 23 | <option value="2">February</option> |
24 | 24 | <option value="3">March</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
34 | 34 | </select> |
35 | 35 | |
36 | 36 | <select name="mydate_day" id="id_mydate_day"> |
37 | | <option value="0">---</option> |
| 37 | <option selected value="">---</option> |
38 | 38 | <option value="1">1</option> |
39 | 39 | <option value="2">2</option> |
40 | 40 | <option value="3">3</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
69 | 69 | </select> |
70 | 70 | |
71 | 71 | <select name="mydate_year" id="id_mydate_year"> |
72 | | <option value="0">---</option> |
| 72 | <option selected value="">---</option> |
73 | 73 | <option value="2007">2007</option> |
74 | 74 | <option value="2008">2008</option> |
75 | 75 | <option value="2009">2009</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
97 | 97 | self.check_html(self.widget, 'mydate', '2010-04-15', html=( |
98 | 98 | """ |
99 | 99 | <select name="mydate_month" id="id_mydate_month"> |
100 | | <option value="0">---</option> |
| 100 | <option value="">---</option> |
101 | 101 | <option value="1">January</option> |
102 | 102 | <option value="2">February</option> |
103 | 103 | <option value="3">March</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
113 | 113 | </select> |
114 | 114 | |
115 | 115 | <select name="mydate_day" id="id_mydate_day"> |
116 | | <option value="0">---</option> |
| 116 | <option value="">---</option> |
117 | 117 | <option value="1">1</option> |
118 | 118 | <option value="2">2</option> |
119 | 119 | <option value="3">3</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
148 | 148 | </select> |
149 | 149 | |
150 | 150 | <select name="mydate_year" id="id_mydate_year"> |
151 | | <option value="0">---</option> |
| 151 | <option value="">---</option> |
152 | 152 | <option value="2007">2007</option> |
153 | 153 | <option value="2008">2008</option> |
154 | 154 | <option value="2009">2009</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
176 | 176 | self.check_html(self.widget, 'mydate', '2010-02-31', html=( |
177 | 177 | """ |
178 | 178 | <select name="mydate_month" id="id_mydate_month"> |
179 | | <option value="0">---</option> |
| 179 | <option value="">---</option> |
180 | 180 | <option value="1">January</option> |
181 | 181 | <option value="2" selected>February</option> |
182 | 182 | <option value="3">March</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
192 | 192 | </select> |
193 | 193 | |
194 | 194 | <select name="mydate_day" id="id_mydate_day"> |
195 | | <option value="0">---</option> |
| 195 | <option value="">---</option> |
196 | 196 | <option value="1">1</option> |
197 | 197 | <option value="2">2</option> |
198 | 198 | <option value="3">3</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
227 | 227 | </select> |
228 | 228 | |
229 | 229 | <select name="mydate_year" id="id_mydate_year"> |
230 | | <option value="0">---</option> |
| 230 | <option value="">---</option> |
231 | 231 | <option value="2007">2007</option> |
232 | 232 | <option value="2008">2008</option> |
233 | 233 | <option value="2009">2009</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
247 | 247 | self.check_html(widget, 'mydate', '', html=( |
248 | 248 | """ |
249 | 249 | <select name="mydate_month" id="id_mydate_month"> |
250 | | <option value="0">---</option> |
| 250 | <option selected value="">---</option> |
251 | 251 | <option value="1">Jan.</option> |
252 | 252 | <option value="2">Feb.</option> |
253 | 253 | <option value="3">March</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
263 | 263 | </select> |
264 | 264 | |
265 | 265 | <select name="mydate_day" id="id_mydate_day"> |
266 | | <option value="0">---</option> |
| 266 | <option selected value="">---</option> |
267 | 267 | <option value="1">1</option> |
268 | 268 | <option value="2">2</option> |
269 | 269 | <option value="3">3</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
298 | 298 | </select> |
299 | 299 | |
300 | 300 | <select name="mydate_year" id="id_mydate_year"> |
301 | | <option value="0">---</option> |
| 301 | <option selected value="">---</option> |
302 | 302 | <option value="2013">2013</option> |
303 | 303 | </select> |
304 | 304 | """ |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
318 | 318 | w = SelectDateWidget(years=('2014',), empty_label='empty_label') |
319 | 319 | |
320 | 320 | # Rendering the default state with empty_label setted as string. |
321 | | self.assertInHTML('<option value="0">empty_label</option>', w.render('mydate', ''), count=3) |
| 321 | self.assertInHTML('<option selected value="">empty_label</option>', w.render('mydate', ''), count=3) |
322 | 322 | |
323 | 323 | w = SelectDateWidget(years=('2014',), empty_label=('empty_year', 'empty_month', 'empty_day')) |
324 | 324 | |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
327 | 327 | w.render('mydate', ''), |
328 | 328 | """ |
329 | 329 | <select name="mydate_month" id="id_mydate_month"> |
330 | | <option value="0">empty_month</option> |
| 330 | <option selected value="">empty_month</option> |
331 | 331 | <option value="1">January</option> |
332 | 332 | <option value="2">February</option> |
333 | 333 | <option value="3">March</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
343 | 343 | </select> |
344 | 344 | |
345 | 345 | <select name="mydate_day" id="id_mydate_day"> |
346 | | <option value="0">empty_day</option> |
| 346 | <option selected value="">empty_day</option> |
347 | 347 | <option value="1">1</option> |
348 | 348 | <option value="2">2</option> |
349 | 349 | <option value="3">3</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
378 | 378 | </select> |
379 | 379 | |
380 | 380 | <select name="mydate_year" id="id_mydate_year"> |
381 | | <option value="0">empty_year</option> |
| 381 | <option selected value="">empty_year</option> |
382 | 382 | <option value="2014">2014</option> |
383 | 383 | </select> |
384 | 384 | """, |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
402 | 402 | w.render('date', '13-08-2010'), |
403 | 403 | """ |
404 | 404 | <select name="date_day" id="id_date_day"> |
405 | | <option value="0">---</option> |
| 405 | <option value="">---</option> |
406 | 406 | <option value="1">1</option> |
407 | 407 | <option value="2">2</option> |
408 | 408 | <option value="3">3</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
437 | 437 | </select> |
438 | 438 | |
439 | 439 | <select name="date_month" id="id_date_month"> |
440 | | <option value="0">---</option> |
| 440 | <option value="">---</option> |
441 | 441 | <option value="1">januari</option> |
442 | 442 | <option value="2">februari</option> |
443 | 443 | <option value="3">maart</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
453 | 453 | </select> |
454 | 454 | |
455 | 455 | <select name="date_year" id="id_date_year"> |
456 | | <option value="0">---</option> |
| 456 | <option value="">---</option> |
457 | 457 | <option value="2007">2007</option> |
458 | 458 | <option value="2008">2008</option> |
459 | 459 | <option value="2009">2009</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
511 | 511 | self.check_html(widget, 'mydate', '', html=( |
512 | 512 | """ |
513 | 513 | <select name="mydate_month" id="id_mydate_month"> |
514 | | <option value="0">---</option> |
| 514 | <option selected value="">---</option> |
515 | 515 | <option value="1">January</option> |
516 | 516 | <option value="2">February</option> |
517 | 517 | <option value="3">March</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
526 | 526 | <option value="12">December</option> |
527 | 527 | </select> |
528 | 528 | <select name="mydate_day" id="id_mydate_day"> |
529 | | <option value="0">---</option> |
| 529 | <option selected value="">---</option> |
530 | 530 | <option value="1">1</option> |
531 | 531 | <option value="2">2</option> |
532 | 532 | <option value="3">3</option> |
… |
… |
class SelectDateWidgetTest(WidgetTest):
|
560 | 560 | <option value="31">31</option> |
561 | 561 | </select> |
562 | 562 | <select name="mydate_year" id="id_mydate_year"> |
563 | | <option value="0">---</option> |
| 563 | <option selected value="">---</option> |
564 | 564 | <option value="2007">2007</option> |
565 | 565 | </select> |
566 | 566 | """ |