How can I display all the tags from each category

118 Views Asked by At

this is link model:

class Link(models.Model)
    user = models.ForeignKey(User)
    url = models.URLField()
    tags = TaggableManager()
    category = models.ForeignKey(Category)

this is category:

class Category(models.Model):
    name = models.CharField(_("Category"), max_length=255)
    user = models.ManyToManyField(User)

if I want to display link.tags in link_detail page I can do it with this:

{% for tag in link.tags.all %}
   <a href="{% url 'tagged' tag.name %}">{{tag}}</a>
{% endfor %}        

But I couldnt figure out how can I display all tags from one category ? Forexample I have 2 links in A category which have 2 tags:python, django. I want to display these like this:

A category tags : python, django

What is the best solution?Thanks for any help.

0

There are 0 best solutions below