Search code examples
pythondjangodjango-taggit

How to filtering tag using Django2.0 and django-taggit0.22.1


I have a problem which I can't resolve. I tried to implement tags features in my blog project in Python/Django 2.0. I installed django-taggit0.22.1.

I have a class Post with atributte tags = TaggableManager()

I also have a few posts object with tags. For example in python manage.py shell I import my Post models and I do command:

post = Post.objects.get(id=1)

I have a post named Post: Django 2.0

then I use

tag = post.tags.all()

"tag" variable shows me this

"QuerySet [<\Tag: django\>], <\Tag: programming\>, <\Tag: jazz\>"

Then I want to filter my tags.

I download all my published posts

published= Post.published.all()

and finally I want do filter posts by tags using this:

published.filter(tags__name__in=['music'])

I see this

error: TypeError: get_path_info() takes 1 positional argument but 2 were given

What is the main problem ?

This filtering method I saw on https://pypi.python.org/pypi/django-taggit

Can you help me?


Solution

  • The latest release django-taggit 0.22.1 adds testing for Django 1.11. There is not yet a release that supports Django 2.0.

    In the meantime, you could try running the branch in pull request 509.