From 867fd7fad5430361d308452a02905dc85458485e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 26 Apr 2013 14:10:04 +0200 Subject: [PATCH 1/1] Handling special case with zero clicks --- questions/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/questions/views.py b/questions/views.py index 9b4b035..43b812b 100644 --- a/questions/views.py +++ b/questions/views.py @@ -53,7 +53,7 @@ class QuestionListView(ListView): minimum_factor = 0.7 for category in context['tag_categories']: annotated_categories[category.id] = category - category.factor = '%.2f' % (minimum_factor + (float(category.click_count) / all_tag_clicks_count)) + category.factor = '%.2f' % (minimum_factor + ((float(category.click_count) / all_tag_clicks_count) if all_tag_clicks_count else 0)) for tag in tags: if tag.category: category = annotated_categories[tag.category.id] -- 2.20.1