diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py index 35bbdd39e1..6e3628ff91 100644 --- a/django/utils/numberformat.py +++ b/django/utils/numberformat.py @@ -25,7 +25,7 @@ def format( module in locale.localeconv() LC_NUMERIC grouping (e.g. (3, 2, 0)). * thousand_sep: Thousand separator symbol (for example ",") """ - if number == "": + if number is None or number == "": return mark_safe(number) use_grouping = ( use_l10n or (use_l10n is None and settings.USE_L10N) diff --git a/tests/utils_tests/test_numberformat.py b/tests/utils_tests/test_numberformat.py index 59fa421682..3c7620c744 100644 --- a/tests/utils_tests/test_numberformat.py +++ b/tests/utils_tests/test_numberformat.py @@ -175,3 +175,4 @@ class TestNumberFormat(SimpleTestCase): def test_empty(self): self.assertEqual(nformat("", "."), "") + self.assertEqual(nformat(None, "."), "None")