Search code examples
django-taggit

django taggit get all users tags from foreignkey lookup


I have the following model

class Entry(models.Model):
    user = models.ForeignKey(User)

    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(default=timezone.now)

    tags = TaggableManager()

I'm trying t get all the tags for a user and the following query isn't working as expected

tags = Tag.objects.filter(entry__user=u)

This is using django-taggit

https://github.com/alex/django-taggit


Solution

  • Looks like

    tags = Tag.objects.filter(entry__user=u)
    

    worked.. I must have had some bad code somewhere.