Open robslotboom opened 7 years ago
Unfortunately this is only supported if the query is restricted to one ContentType...
Unfortunately, this caused major bugs with Django, and so had to be taken out.
I'll leave open for now, however, as it should go back into once Django has released a few more versions and I can drop support for the broken ones.
I'm using prefetch with watson search and so far it works fine.
products = watson.search(clean_query, models=(Product,)).prefetch_related('object', 'object__engagement_set')
Excellent. I'd take a MR that puts this feature back in.
2016...
Pardon?
That’s 4 years back :-D
Still I think it only works if you have only 1 model / content_type in the results and you have to know which one up front.
Unless you only want to prefetch object
, which is in itself already a performance improvement if you access it in your search results.
Maybe interesting.
To limit the amount of queries you can do the following in the search view:
self.object_list = self.get_queryset().prefetch_related('object')
Cheers,
Robert