Created
December 14, 2011 04:51
-
-
Save pilate/1475311 to your computer and use it in GitHub Desktop.
Sort Haystack SearchResults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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