Permalink
Browse files

Updated `TimeInput` changes from [8491] to allow time widgets to be u…

…sed with unicode values. Fixes #7499.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8549 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 7e06b69 commit cbd574881c48e095b118031c850367f86b597a2e @jacobian jacobian committed Aug 25, 2008
Showing with 6 additions and 1 deletion.
  1. +2 −1 django/forms/widgets.py
  2. +4 −0 tests/regressiontests/forms/widgets.py
View
@@ -16,6 +16,7 @@
from django.utils.encoding import StrAndUnicode, force_unicode
from django.utils.safestring import mark_safe
from django.utils import datetime_safe
+from datetime import time
from util import flatatt
from urlparse import urljoin
@@ -307,7 +308,7 @@ class TimeInput(Input):
def render(self, name, value, attrs=None):
if value is None:
value = ''
- elif hasattr(value, 'replace'):
+ elif isinstance(value, time):
value = value.replace(microsecond=0)
return super(TimeInput, self).render(name, value, attrs)
@@ -1104,5 +1104,9 @@
u'<input type="text" name="time" value="12:51:34" />'
>>> w.render('time', datetime.time(12, 51))
u'<input type="text" name="time" value="12:51:00" />'
+
+We should be able to initialize from a unicode value.
+>>> w.render('time', u'13:12:11')
+u'<input type="text" name="time" value="13:12:11" />'
"""

0 comments on commit cbd5748

Please sign in to comment.