Django taggit query error: must be "model_name" instance

Viewed 14

I have a very simple Photo class which uses django_taggit

class Photo(models.Model):
    ... some other fields
    tags = TaggableManager(blank=True)

Oddly enough, even simple query like this:

blue_tag = Tag.objects.get(name='blue')
q1 = Photo.objects.filter(tags=blue_tag)
some_tags = Tag.objects.filter(name__icontains='b')
q1 = Photo.objects.filter(tags__in=some_tags)

will result in the following error....

Cannot query "blue": Must be "Photo" instance.

Which is odd...given the fact that I'm passing Tag objects...

1 Answers

Well... I just reinstalled the all package forcing an upgrade like so

pip install --upgrade --force-reinstall django-taggit

when doing so be carefull in faking migrations

python manage.py migrate --fake

So you do preserve the DB.

Hope is can be helpful to others

Related