Here comes another problem from the Django-Haystack custom queryset.
How can I create a Django Rest Framework List View (or whatever view) that uses Django-Haystack's custom queryset attribute as a queryset?
The difference is basically that where the regular queryset attribute contains regular objects, the Django-Haystack's custom queryset contains a dictionary with an 'object' property that returns the object.
Queryset:
[<ModelInstance_1>, <ModelInstance_2>]
SearchQuerySet
[{object: <ModelInstance_1>}, {object: <ModelInstance_2>}]
I have searched before posting, and found a couple of answers but they are using outdated versions which work very differently than the way it works now.
I am currently using something like this:
class SearchProjectsView(generics.ListAPIView):
serializer_class = ArchiveProjectSerializer
model = Project
def get_queryset(self):
queryset = []
for result in SearchQuerySet().models(Project).filter(content=Clean(self.request.QUERY_PARAMS.get('q', ''))):
queryset.append(result.object)
return queryset
But as soon as I extend this with pagination or any other minor issue it will become a problem..