def haystack_monkey_load(sqs): """ it loads all Items for given SearchQuerySet and attaches them as "object" in each SearchResult """ model_dict = {'app.item': Item, 'another_app.comment': Comment} for model_key, model in model_dict.items(): items_id = [sr.pk for sr in sqs if sr.app_label+"."+sr.model_name == model_key] items = model.objects.filter(id__in=items_id).select_related() for item in items: for sr in sqs: if item.id == sr.pk and sr.app_label+"."+sr.model_name == model_key: sr.object = item return sqs class SpecialSearchView(SearchView): def build_page(self): """ for example special SearchView that uses haystack_monkey_load for pagination """ paginator = paginator(self.results, self.results_per_page) try: page = paginator.page(self.request.GET.get('page', 1)) page.object_list = haystack_monkey_load(page.object_list) except InvalidPage: raise Http404 return (paginator, page)