From 6f9fe3c1592ba2cc44f4197a37fd88447e1a1c53 Mon Sep 17 00:00:00 2001 From: "A.Avenel" Date: Sat, 12 Oct 2013 17:28:15 +0200 Subject: [PATCH] bugfix #104 : ZeroDivisionError - test if self.owers is null before returning value --- budget/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/budget/models.py b/budget/models.py index 900b1d0..c1372c0 100644 --- a/budget/models.py +++ b/budget/models.py @@ -218,7 +218,10 @@ class Bill(db.Model): def pay_each(self): """Compute what each person has to pay""" - return round(self.amount / len(self.owers), 2) + if self.owers: + return round(self.amount / len(self.owers), 2) + else: + return 0 def __repr__(self): return "" % (self.amount,