jazzband / django-taggit

Simple tagging for django
https://django-taggit.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.28k stars 623 forks source link

Mypy Support For TaggableManager #902

Open jmichalicek opened 3 days ago

jmichalicek commented 3 days ago

I have a model with a TaggableManager for a model with direct foreign keys defined, per the docs:

class TaggedRecipe(TaggedItemBase):
    content_object = models.ForeignKey("Recipe", on_delete=models.CASCADE)

    def __str__(self) -> str:
        return f"{self.content_object}: {self.tag}"

and then on the Recipe model:

tags = TaggableManager(through=TaggedRecipe)

When running mypy, I get an error about that line error: Couldn't resolve related manager for relation 'tagged_recipes' with the actual error being [django-manager-missing]

This is with the following versions: Django 5.0.6 django-taggit 5.0.1 mypy 1.10.1 django-stubs 5.0.2 django-stubs-ext 5.0.2

rtpg commented 3 days ago

I guess that's from the mypy django plugin? Will need to look at into if we can get it to play nicely with django-taggit. Thanks for the clear report!