Ticket #6501: force_unicode.patch

File force_unicode.patch, 800 bytes (added by Moof, 17 years ago)

Fixes force_unicode to take Decimal values into account

  • utils/encoding.py

     
    11import types
    22import urllib
    33import datetime
     4import decimal
    45
    56from django.utils.functional import Promise
    67from django.utils.safestring import SafeData, mark_safe
     
    4344
    4445    If strings_only is True, don't convert (some) non-string-like objects.
    4546    """
    46     if strings_only and isinstance(s, (types.NoneType, int, long, datetime.datetime, datetime.date, datetime.time, float)):
     47    if strings_only and isinstance(s, (types.NoneType, int, long, datetime.datetime, datetime.date, datetime.time, float, decimal.Decimal)):
    4748        return s
    4849    try:
    4950        if not isinstance(s, basestring,):
Back to Top