diff options
| author | Varun Sharma <varun@sharmalabs.org> | 2015-02-08 03:06:45 +0530 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-02-08 20:09:04 +0100 |
| commit | b44a56c3080312ab94679a396e6b60a18f9b6463 (patch) | |
| tree | 489a897b2e95c9234caacc00be3928efcf8f1baa | |
| parent | edbf6de7536f7a6c1e5df019a5e1947d2c9dadf8 (diff) | |
[1.8.x] Fixed #24181 -- Fixed multi-char THOUSAND_SEPARATOR insertion
Report and original patch by Kay Cha.
Backport of 540ca563de from master.
| -rw-r--r-- | django/utils/numberformat.py | 2 | ||||
| -rw-r--r-- | tests/utils_tests/test_numberformat.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py index c3cf55bca5..a70799852d 100644 --- a/django/utils/numberformat.py +++ b/django/utils/numberformat.py @@ -47,7 +47,7 @@ def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', int_part_gd = '' for cnt, digit in enumerate(int_part[::-1]): if cnt and not cnt % grouping: - int_part_gd += thousand_sep + int_part_gd += thousand_sep[::-1] int_part_gd += digit int_part = int_part_gd[::-1] return sign + int_part + dec_part diff --git a/tests/utils_tests/test_numberformat.py b/tests/utils_tests/test_numberformat.py index 84ba378e46..43579060bc 100644 --- a/tests/utils_tests/test_numberformat.py +++ b/tests/utils_tests/test_numberformat.py @@ -26,6 +26,9 @@ class TestNumberFormat(TestCase): self.assertEqual(nformat('1234', '.', grouping=2, thousand_sep=',', force_grouping=True), '12,34') self.assertEqual(nformat('-1234.33', '.', decimal_pos=1), '-1234.3') + self.assertEqual(nformat('10000', '.', grouping=3, + thousand_sep='comma', force_grouping=True), + '10comma000') def test_large_number(self): most_max = ('{}179769313486231570814527423731704356798070567525844996' |
