Ticket #14807: patch.2

File patch.2, 1.5 KB (added by Klaas van Schelven, 13 years ago)
Line 
1diff -r 35aeedea954d django/utils/formats.py
2--- a/django/utils/formats.py Mon Nov 29 06:24:14 2010 +0000
3+++ b/django/utils/formats.py Thu Dec 02 23:05:05 2010 +0100
4@@ -6,6 +6,7 @@
5 from django.utils.importlib import import_module
6 from django.utils.encoding import smart_str
7 from django.utils import dateformat, numberformat, datetime_safe
8+from django.utils.safestring import mark_safe
9
10 # format_cache is a mapping from (format_type, lang) to the format string.
11 # By using the cache, it is possible to avoid running get_format_modules
12@@ -114,6 +115,8 @@
13 If use_l10n is provided and is not None, that will force the value to
14 be localized (or not), overriding the value of settings.USE_L10N.
15 """
16+ if isinstance(value, bool):
17+ return mark_safe(unicode(value))
18 if isinstance(value, (decimal.Decimal, float, int, long)):
19 return number_format(value, use_l10n=use_l10n)
20 elif isinstance(value, datetime.datetime):
21diff -r 35aeedea954d tests/regressiontests/i18n/tests.py
22--- a/tests/regressiontests/i18n/tests.py Mon Nov 29 06:24:14 2010 +0000
23+++ b/tests/regressiontests/i18n/tests.py Thu Dec 02 23:05:05 2010 +0100
24@@ -268,6 +268,7 @@
25 self.assertEqual(u'66.666,666', localize(self.n))
26 self.assertEqual(u'99.999,999', localize(self.f))
27 self.assertEqual(u'10.000', localize(self.l))
28+ self.assertEqual(u'True', localize(True))
29
30 settings.USE_THOUSAND_SEPARATOR = False
31 self.assertEqual(u'66666,666', localize(self.n))
Back to Top