-
-
Notifications
You must be signed in to change notification settings - Fork 521
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
What's wrong
class Tag(models.Model):
pass
class Article(models.Model):
tags = models.ManyToManyField(to=Tag, related_name="articles", blank=True)
def method(self):
published_articles = Article.objects.exclude(pk=self.pk)
for tag in self.tags.all().prefetch_related(
Prefetch("articles", published_articles, to_attr="published_articles")
):
print(tag.published_articles)src/articles/models.py:147: error: "Tag" has no attribute "published_articles"
How is that should be
published_articles should be recognized as a valid attribute for tag in the loop, as defined in the to_attr of the Prefetch instance.
System information
- OS: macOS 12.1 (21C52)
pythonversion: Python 3.10.0djangoversion: 4.0mypyversion: mypy 0.930django-stubsversion: 1.9.0django-stubs-extversion: 0.3.1
tboz203, ErikKalkoken, konyskoCic, moffire, Pixel-Jack and 33 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working