diff --git a/app/templates/tags.html b/app/templates/tags.html index 142bba2..0c32fe9 100644 --- a/app/templates/tags.html +++ b/app/templates/tags.html @@ -7,7 +7,7 @@

Tags

{% if tags %} {% for tag in tags %} - 📌 {{ tag.name }} + 📌 {{ tag.tags__name }} {{ tag.count }}   {% endfor %} {% endif %} diff --git a/app/views.py b/app/views.py index 274e3ce..1d1bd80 100644 --- a/app/views.py +++ b/app/views.py @@ -1,7 +1,7 @@ import time from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator -from django.db.models import Q +from django.db.models import Q, Count from django.shortcuts import render from django.views.generic import TemplateView from taggie.parser import generate_tags @@ -73,7 +73,8 @@ def latest(request): def tags(request): """view for the tags""" - tags = Tag.objects.all() + tags = Tutorial.objects.filter(publish=True).values('tags__name').annotate(count=Count('tags')) + context = { 'tags': tags, 'title': 'Tags'