From 7ba2a0db20c37a5b1500434ca4ed48022311c171 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 21 Jun 2024 15:51:41 -0400 Subject: [PATCH] Fixed Number.__str__() crash when float/decimal_value is None in expressions tests models. --- tests/expressions/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/expressions/models.py b/tests/expressions/models.py index 43dd235fb5ac..31891a13d7c1 100644 --- a/tests/expressions/models.py +++ b/tests/expressions/models.py @@ -56,7 +56,11 @@ class Number(models.Model): decimal_value = models.DecimalField(max_digits=20, decimal_places=17, null=True) def __str__(self): - return "%i, %.3f, %.17f" % (self.integer, self.float, self.decimal_value) + return "%i, %s, %s" % ( + self.integer, + "%.3f" % self.float if self.float is not None else None, + "%.17f" % self.decimal_value if self.decimal_value is not None else None, + ) class Experiment(models.Model):