From 4375ad983f2adbfdd091a1e92a847dd108d04c02 Mon Sep 17 00:00:00 2001
From: Jimmy Angelakos <vyruss@hellug.gr>
Date: Fri, 9 Sep 2022 23:35:54 +0100
Subject: [PATCH] Fix numberformat.py "string index out of range"
When `if str_number[0] == "-"` encounters a number field that's null when formatting for the admin `list_display` this causes an `IndexError: string index out of range`
---
django/utils/numberformat.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
index 488d6a77cdd1..e952af3fdc6d 100644
a
|
b
|
def format(
|
68 | 68 | str_number = "{:f}".format(number) |
69 | 69 | else: |
70 | 70 | str_number = str(number) |
71 | | if str_number[0] == "-": |
| 71 | if str_number and str_number[0] == "-": |
72 | 72 | sign = "-" |
73 | 73 | str_number = str_number[1:] |
74 | 74 | # decimal part |