From 391ac1beaa05b7e11af45c7c2ba4ed03669b1ee4 Mon Sep 17 00:00:00 2001 From: Date: Fri, 8 Dec 2017 01:29:07 +0300 Subject: [PATCH] heroku --- blog/models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/blog/models.py b/blog/models.py index 4784562..80b3515 100644 --- a/blog/models.py +++ b/blog/models.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- from django.db import models from django.utils import timezone @@ -23,14 +23,16 @@ class Post(models.Model): def __unicode__(self): return self.title - + def font_size(self): min_font = 12 max_font = 28 v = Tag.objects.all().annotate(c = Count('post')).filter(c__gt = 0).aggregate(Min('c'), Max('c')) max_tag, min_tag = v["c__max"], v["c__min"] - step = (max_font - min_font)/float(max_tag-min_tag) + + try: step = (max_font - min_font)/float(max_tag-min_tag) + except: step = 1 tag_count = Post.objects.filter(tags__name=self.name).count() #print Tag.objects.filter(name=self.name).annotate(c = Count('post')) font = int(min_font + (tag_count-min_tag)*step)