How to prefetch Wagtail post tags?
Asked Answered
L

0

2

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!

Laband answered 9/8, 2018 at 12:33 Comment(2)
Can you provide a minimal working example?Anole
@Anole You can find their demo here. It has the same problem. DemoLaband

© 2022 - 2024 — McMap. All rights reserved.