mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #5553 -- Fixed a serialization problem with datetime and time objects. Thanks to pigletto for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6406 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import types
|
||||
import urllib
|
||||
import datetime
|
||||
from django.utils.functional import Promise
|
||||
|
||||
class StrAndUnicode(object):
|
||||
@@ -30,7 +31,7 @@ def force_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
|
||||
|
||||
If strings_only is True, don't convert (some) non-string-like objects.
|
||||
"""
|
||||
if strings_only and isinstance(s, (types.NoneType, int, long)):
|
||||
if strings_only and isinstance(s, (types.NoneType, int, long, datetime.datetime, datetime.time, float)):
|
||||
return s
|
||||
if not isinstance(s, basestring,):
|
||||
if hasattr(s, '__unicode__'):
|
||||
|
||||
Reference in New Issue
Block a user