Permalink
Browse files

fix for division by 0

  • Loading branch information...
David Cramer authored and alex committed Nov 23, 2009
1 parent 5d5e4c8 commit 8841dcf4d19dfbf002f3d7058f4011cb9bb7e018
Showing with 4 additions and 1 deletion.
  1. +4 −1 django_histograms/utils.py
@@ -113,7 +113,10 @@ def get_report(self):
total = sum(o for m in months.itervalues() for o in m[1])
max_num = max(o for m in months.itervalues() for o in m[1])
- ratio = total / max_num * 100
+ if not (total and max_num):
+ ratio = 0
+ else:
+ ratio = total / max_num * 100
return {
"results": months.values(),

0 comments on commit 8841dcf

Please sign in to comment.