1
0
mirror of https://github.com/django/django.git synced 2025-02-27 11:05:12 +00:00

Fixed Number.__str__() crash when float/decimal_value is None in expressions tests models.

This commit is contained in:
Tim Graham 2024-06-21 15:51:41 -04:00 committed by GitHub
parent 72b7aecbbf
commit 7ba2a0db20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,7 +56,11 @@ class Number(models.Model):
decimal_value = models.DecimalField(max_digits=20, decimal_places=17, null=True) decimal_value = models.DecimalField(max_digits=20, decimal_places=17, null=True)
def __str__(self): 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): class Experiment(models.Model):