Permalink
Browse files

fix for division by 0

  • Loading branch information...
David Cramer David Cramer
David Cramer authored and David Cramer committed Nov 23, 2009
1 parent 5d5e4c8 commit 0a3aded8d2e4f6419bc8d6878645c6db1b47620a
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 0a3aded

Please sign in to comment.