Skip to content

Mypy Support For TaggableManager #902

@jmichalicek

Description

@jmichalicek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions