From fb337243f2e664c4dfc5838c601905864845b6d9 Mon Sep 17 00:00:00 2001 From: Ashley Mathew Date: Wed, 22 Oct 2014 14:20:30 -0400 Subject: [PATCH] Prevent the errors caused by empty results [PD-513] --- saved_search/groupsearch.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/saved_search/groupsearch.py b/saved_search/groupsearch.py index 191fc68..c4507aa 100644 --- a/saved_search/groupsearch.py +++ b/saved_search/groupsearch.py @@ -163,9 +163,12 @@ def search(self, query_string, sort_by=None, start_offset=0, end_offset=None, e) raw_results = [EmptyResults()] - return [self._process_results(res, highlight=highlight, - result_class=result_class) - for res in raw_results.grouped.iteritems()] + if hasattr(raw_results, 'grouped'): + return [self._process_results(res, highlight=highlight, + result_class=result_class) + for res in raw_results.grouped.iteritems()] + else: + return [] def _process_results(self, raw_results, highlight=False, result_class=None): from haystack import connections