class Meta:
verbose_name = _("Tag Category")
- verbose_name_plural = _("Tag Categries")
+ verbose_name_plural = _("Tag Categories")
def __unicode__(self):
return self.name
slug += "_%d" % i
return slug
- category = models.ForeignKey(TagCategory, blank = True, null = True, on_delete = models.SET_NULL)
+ category = models.ForeignKey(TagCategory, blank = True, null = True, on_delete = models.SET_NULL, related_name = 'tags')
click_count = models.IntegerField(null = False, default = 0)
class Meta:
technologii informacyjno-komunikacyjnych oraz posiada wieloletnie
doświadczenie doradcze w tej tematyce.</p>
+Kategorie:
+{% for category in tag_categories %}
+ <p>{{category}} {{category.click_count}}</p>
+{% endfor %}
+
Tematy:
{% if tag %}<a href=".">wszystkie</a>
{% else %}<strong>wszystkie</strong>
from django.views.generic import ListView
from django.views.generic.edit import FormView
from .forms import QuestionForm
-from .models import Question, Tag
+from .models import Question, Tag, TagCategory
class QuestionFormView(FormView):
context['tags'] = Tag.objects.filter(items__question__published=True
).annotate(c=models.Count('items__tag')).order_by('-c', 'slug')
context['tag'] = self.tag
+ context['tag_categories'] = TagCategory.objects.all().annotate(click_count = models.Sum('tags__click_count'))
return context