Javed
Javed

Reputation: 6239

haystack SearchQuerySet() is returning list instead of SearchQuerySet object

this is my get_queryset(): method in the view

    def get_queryset(self):
       #by here the search query is getting executed
        self.vendor_filter=self.request.GET.get('select_vendor', 'all')
        self.search_query=self.request.GET.get('q', "")
        self.sort_by=self.request.GET.get('sort_by', "relevance")
        queryset=SearchQuerySet().all()[:50]
        return queryset

this method is throwing 'list' object has no attribute 'all' error. However I ran this SearchQuerySet().all() in django shell it is returning correct results. enter image description here.

it is very annoying issue. I dont know what is the mistake?, I am using whoosh with django-haystack search.

Upvotes: 2

Views: 574

Answers (1)

Javed
Javed

Reputation: 6239

I found the reason why, the code queryset=SearchQuerySet().all()[:50] was converting the SearchQuerySet object to list. I changed it to queryset=SearchQuerySet().all() now it works as expected. It took me whole day to figure out. But still I don't know why it was doing that without throwing an exception or error.

Upvotes: 2

Related Questions