Ticket #34000: c10cec4352d7cfa7c848f2aaf590e1692e1b92ae.diff

File c10cec4352d7cfa7c848f2aaf590e1692e1b92ae.diff, 1.1 KB (added by Jimmy Angelakos, 2 years ago)

updated patch

  • django/utils/numberformat.py

    diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
    index 488d6a77cd..c47724126c 100644
    a b def format(  
    2525        module in locale.localeconv() LC_NUMERIC grouping (e.g. (3, 2, 0)).
    2626    * thousand_sep: Thousand separator symbol (for example ",")
    2727    """
     28    if number is None:
     29        return mark_safe(None)
     30    if number == "":
     31        return mark_safe("")
    2832    use_grouping = (
    2933        use_l10n or (use_l10n is None and settings.USE_L10N)
    3034    ) and settings.USE_THOUSAND_SEPARATOR
  • tests/utils_tests/test_numberformat.py

    diff --git a/tests/utils_tests/test_numberformat.py b/tests/utils_tests/test_numberformat.py
    index cec3e4c385..e521b43f96 100644
    a b class TestNumberFormat(SimpleTestCase):  
    172172
    173173        price = EuroDecimal("1.23")
    174174        self.assertEqual(nformat(price, ","), "€ 1,23")
     175
     176    def test_empty(self):
     177        self.assertEqual(nformat(None, "."), "None")
     178        self.assertEqual(nformat("", "."), "")
Back to Top