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, 2019 in Python by ana1504.k
• 7,910 points
2,519 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, 2019 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer
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
2,780 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,560 points

edited Dec 18, 2018 by Nymeria 6,836 views
+1 vote
1 answer

Django model iterate fields

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

answered Apr 10, 2019 in Python by SDeb
• 13,300 points
5,139 views
0 votes
0 answers

"Post Image data using POSTMAN"

I am trying to POST data to ...READ MORE

May 21, 2022 in Others by Kichu
• 19,040 points
1,087 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
1,959 views
0 votes
1 answer

Get path from open file in Python

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

answered Jan 16, 2019 in Python by SDeb
• 13,300 points
1,391 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, 2019 in Python by SDeb
• 13,300 points
1,698 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP