Mike
Mike

Reputation: 7841

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

Upvotes: 4

Views: 250

Answers (1)

Mike
Mike

Reputation: 7841

Looks like

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

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

Upvotes: 1

Related Questions