django-taggit icon indicating copy to clipboard operation
django-taggit copied to clipboard

Mypy Support For TaggableManager

Open jmichalicek opened this issue 7 months ago • 1 comments

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

jmichalicek avatar Jul 04 '24 22:07 jmichalicek