问题
I have around 10 posts and it is generating about 100 queries to fetch post tags. The taggit
library Wagtail used underneath supportprefetch_related, but adding prefetch_related
has no effect. After more research, I found that the culprit is Wagtail's ClusterTaggableManager
that overrides taggit
's TaggableManager
.
In the changelog, it says
2.0 (22.04.2016)
~~~~~~~~~~~~~~~~
* Fix: prefetch_related on a ClusterTaggableManager no longer fails (but doesn't prefetch either)
It has been 2 years and it seems they are not going to fix it anytime soon. So... Is there anything I can do to reduce the number of queries? Thanks!
来源:https://stackoverflow.com/questions/51767172/how-to-prefetch-wagtail-post-tags