How to prefetch Wagtail post tags?

喜夏-厌秋 提交于 2020-06-18 01:26:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!