Ticket #5917: SelectDateWidget_with_test.2.diff
File SelectDateWidget_with_test.2.diff, 1.2 KB (added by , 17 years ago) |
---|
-
django/newforms/extras/widgets.py
32 32 33 33 def render(self, name, value, attrs=None): 34 34 try: 35 value = datetime.date(*map(int, value.split('-'))) 35 if isinstance(value, basestring): 36 value = datetime.date(*map(int, value.split('-'))) 36 37 year_val, month_val, day_val = value.year, value.month, value.day 37 except (AttributeError, TypeError,ValueError):38 except (AttributeError, ValueError): 38 39 year_val = month_val = day_val = None 39 40 40 41 output = [] -
tests/regressiontests/forms/extra.py
143 143 <option value="2015">2015</option> 144 144 <option value="2016">2016</option> 145 145 </select> 146 >>> w.render('mydate', datetime.date(2010, 4, 15)) == w.render('mydate', '2010-04-15') 147 True 146 148 147 149 Using a SelectDateWidget in a form: 148 150