Skip to content

Instantly share code, notes, and snippets.

@pilate
Created December 14, 2011 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pilate/1475311 to your computer and use it in GitHub Desktop.
Save pilate/1475311 to your computer and use it in GitHub Desktop.
Sort Haystack SearchResults
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}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment