Get all tags from taggit

0 votes

How to get all the unique tags from django-taggit? I want to display all the tags in a side bar. Right now, I am able to get all the tags for a particular post, but I need to get all the unique tags in the entire blog.

code in models.py:

from django.db import models
from taggit.managers import TaggableManager

# Create your models here.
class Post(models.Model):
    title = models.CharField(max_length=100)
    body = models.TextField()
    created = models.DateTimeField()
    tags = TaggableManager()

So, how do I do this?

Aug 5 in Python by ana1504.k
• 7,870 points
9 views

1 answer to this question.

0 votes

You can use all() to get all the tags in your database as follows:

from taggit.models import Tag
tags = Tag.objects.all()
answered Aug 5 by SDeb
• 13,160 points

Related Questions In Python

0 votes
1 answer

How to get text label from SAP using pywinauto[python]

Hi. Can you please tell me what ...READ MORE

answered Jun 28, 2018 in Python by Nietzsche's daemon
• 4,260 points
314 views
0 votes
1 answer

How to get all related Django model objects in Python?

This actually gives you the property names ...READ MORE

answered Nov 14, 2018 in Python by Nymeria
• 3,500 points

edited Dec 18, 2018 by Nymeria 489 views
0 votes
1 answer

Django model iterate fields

You can try the following: getattr(foo.__class__, <field_name>)   This should ...READ MORE

answered Apr 10 in Python by SDeb
• 13,160 points
85 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,790 points
127 views
0 votes
1 answer
0 votes
1 answer

Get path from open file in Python

The key here is the name attribute ...READ MORE

answered Jan 16 in Python by SDeb
• 13,160 points
18 views
0 votes
1 answer

Sum of distances from a point to all other points

You can use cdist - In [1]: from scipy.spatial.distance import ...READ MORE

answered Jun 10 in Python by SDeb
• 13,160 points
18 views