Ticket #7499: time_input_widget.3.diff
File time_input_widget.3.diff, 1.3 KB (added by , 16 years ago) |
---|
-
django/forms/widgets.py
16 16 from django.utils.encoding import StrAndUnicode, force_unicode 17 17 from django.utils.safestring import mark_safe 18 18 from django.utils import datetime_safe 19 from datetime import time 19 20 from util import flatatt 20 21 from urlparse import urljoin 21 22 … … 307 308 def render(self, name, value, attrs=None): 308 309 if value is None: 309 310 value = '' 310 elif hasattr(value, 'replace'):311 elif isinstance(value, time): 311 312 value = value.replace(microsecond=0) 312 313 return super(TimeInput, self).render(name, value, attrs) 313 314 -
tests/regressiontests/forms/widgets.py
1104 1104 u'<input type="text" name="time" value="12:51:34" />' 1105 1105 >>> w.render('time', datetime.time(12, 51)) 1106 1106 u'<input type="text" name="time" value="12:51:00" />' 1107 1108 We should be able to initialize from a unicode value. 1109 >>> w.render('time', u'13:12:11') 1110 u'<input type="text" name="time" value="13:12:11" />' 1107 1111 """ 1108 1112