Skip to content

Commit

Permalink
Fixed Number.__str__() crash when float/decimal_value is None in expr…
Browse files Browse the repository at this point in the history
…essions tests models.
  • Loading branch information
timgraham authored Jun 21, 2024
1 parent 72b7aec commit 7ba2a0d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/expressions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7ba2a0d

Please sign in to comment.