summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/utils/formats.py2
-rw-r--r--docs/releases/3.1.txt3
-rw-r--r--docs/topics/i18n/formatting.txt3
-rw-r--r--tests/i18n/tests.py1
4 files changed, 9 insertions, 0 deletions
diff --git a/django/utils/formats.py b/django/utils/formats.py
index d5e5a555f6..028e11415a 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -197,6 +197,8 @@ def localize(value, use_l10n=None):
elif isinstance(value, bool): # Make sure booleans don't get treated as numbers
return str(value)
elif isinstance(value, (decimal.Decimal, float, int)):
+ if use_l10n is False:
+ return str(value)
return number_format(value, use_l10n=use_l10n)
elif isinstance(value, datetime.datetime):
return date_format(value, 'DATETIME_FORMAT', use_l10n=use_l10n)
diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt
index c489f9cd89..ba96ea670f 100644
--- a/docs/releases/3.1.txt
+++ b/docs/releases/3.1.txt
@@ -677,6 +677,9 @@ Miscellaneous
* The undocumented ``django.contrib.postgres.fields.jsonb.JsonAdapter`` class
is removed.
+* The :ttag:`{% localize off %} <localize>` tag and :tfilter:`unlocalize`
+ filter no longer respect :setting:`DECIMAL_SEPARATOR` setting.
+
.. _deprecated-features-3.1:
Features deprecated in 3.1
diff --git a/docs/topics/i18n/formatting.txt b/docs/topics/i18n/formatting.txt
index 3dbb10f2dc..f58ff0e963 100644
--- a/docs/topics/i18n/formatting.txt
+++ b/docs/topics/i18n/formatting.txt
@@ -142,6 +142,9 @@ To force localization of a single value, use :tfilter:`localize`. To
control localization over a large section of a template, use the
:ttag:`localize` template tag.
+Returns a string representation for unlocalized numbers (``int``, ``float``,
+or ``Decimal``).
+
.. _custom-format-files:
Creating custom format files
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 9b2d1258bc..affda21fb4 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1218,6 +1218,7 @@ class FormattingTests(SimpleTestCase):
for use_l10n in [True, False]:
with self.subTest(use_l10n=use_l10n), self.settings(
USE_L10N=use_l10n,
+ DECIMAL_SEPARATOR=',',
USE_THOUSAND_SEPARATOR=True,
THOUSAND_SEPARATOR='°',
NUMBER_GROUPING=2,