[Answer]-Using Haystack search with Django Tables 2 views

1👍

Presuming that creating your PersonTable instance with a SearchQuerySet is not an option, you could try passing a list of the Person objects from your search.

def search(request):
    # Let's say there's some logic here for querying your search engine
    # using Haystack, and `results` is a SearchQuerySet of Person results
    table = PersonTable([result.object for result in results])
    RequestConfig(request).configure(table)
    return render(request, 'people.html', {'table': table})

Otherwise your problem statement that you need to pass the primary keys of the results to the view function is a little unclear.

Leave a comment