public
Created

Sort Haystack SearchResults

  • Download Gist
searchview.py
Python
1 2 3 4 5 6 7 8 9 10 11
from haystack.views import SearchView
 
class CustomSearch(SearchView):
def extra_context(self):
seg_results = {}
for result in self.results:
if not result.model_name in seg_results:
seg_results[result.model_name] = [result]
else:
seg_results[result.model_name].append(result)
return {'sorted_results':seg_results}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.