diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-02-08 10:58:54 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-02-08 11:00:36 +0100 |
| commit | cb173bb088e32df3d9ee8bee3c579d88ea713e8f (patch) | |
| tree | 62a8c7fd1704a84be7c6786d34856b0047e5fa3e /django/contrib | |
| parent | 227ef29cff8ded8187c48b0aa955264cf83a01a4 (diff) | |
[4.2.x] Fixed #35172 -- Fixed intcomma for string floats.
Thanks Warwick Brown for the report.
Regression in 55519d6cf8998fe4c8f5c8abffc2b10a7c3d14e9.
Backport of 2f14c2cedc9c92373471c1f98a80c81ba299584a from main.
Diffstat (limited to 'django/contrib')
| -rw-r--r-- | django/contrib/humanize/templatetags/humanize.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py index 2c26f8944a..19000c185c 100644 --- a/django/contrib/humanize/templatetags/humanize.py +++ b/django/contrib/humanize/templatetags/humanize.py @@ -80,6 +80,8 @@ def intcomma(value, use_l10n=True): if match: prefix = match[0] prefix_with_commas = re.sub(r"\d{3}", r"\g<0>,", prefix[::-1])[::-1] + # Remove a leading comma, if needed. + prefix_with_commas = re.sub(r"^(-?),", r"\1", prefix_with_commas) result = prefix_with_commas + result[len(prefix) :] return result |
