summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/utils/formats.py5
-rw-r--r--tests/regressiontests/i18n/tests.py1
2 files changed, 5 insertions, 1 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py
index bf48a4fbe0..7b1d23db33 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -6,6 +6,7 @@ from django.utils.translation import get_language, to_locale, check_for_language
from django.utils.importlib import import_module
from django.utils.encoding import smart_str
from django.utils import dateformat, numberformat, datetime_safe
+from django.utils.safestring import mark_safe
# format_cache is a mapping from (format_type, lang) to the format string.
# By using the cache, it is possible to avoid running get_format_modules
@@ -93,7 +94,9 @@ def localize(value):
Checks if value is a localizable type (date, number...) and returns it
formatted as a string using current locale format
"""
- if isinstance(value, (decimal.Decimal, float, int, long)):
+ if isinstance(value, bool):
+ return mark_safe(unicode(value))
+ elif isinstance(value, (decimal.Decimal, float, int, long)):
return number_format(value)
elif isinstance(value, datetime.datetime):
return date_format(value, 'DATETIME_FORMAT')
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index 77d5883265..99f9fe1303 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -250,6 +250,7 @@ class FormattingTests(TestCase):
self.assertEqual(u'66.666,666', localize(self.n))
self.assertEqual(u'99.999,999', localize(self.f))
self.assertEqual(u'10.000', localize(self.l))
+ self.assertEqual(u'True', localize(True))
settings.USE_THOUSAND_SEPARATOR = False
self.assertEqual(u'66666,666', localize(self.n))