Fix tag cloud generating code

It now works even if there are no tags.
This commit is contained in:
Gergely Polonkai 2014-06-13 08:23:50 +02:00
parent 4f8db2dc97
commit 8820dd89ba
1 changed files with 9 additions and 10 deletions

View File

@ -11,6 +11,7 @@ def randomheader(request):
return {'header': header_file}
def tagcloud(request):
tagcloud = []
tagcloudlist = Tag.objects.annotate(ct=Count('taggit_taggeditem_items')).order_by('-ct')
if (len(tagcloudlist) > 0):
@ -20,8 +21,6 @@ def tagcloud(request):
if (tmax == tmin):
tmax += 1
tagcloud = []
for cloudelement in tagcloudlist:
tagcount = cloudelement.ct