django-tables2 icon indicating copy to clipboard operation
django-tables2 copied to clipboard

Haystack Example

Open AndreGuerra123 opened this issue 6 years ago • 4 comments

Hello, Similarly to the provided example with 'django_filters' package for filtering the data, would it be possible to include an example using Haystack since from the available pull requests it seems integration is feasible. Best regards,

AndreGuerra123 avatar Jan 03 '19 17:01 AndreGuerra123

You are welcome to contribute to the docs, I am not a haystack user myself, so I am not able to effectively create the example.

jieter avatar Jan 04 '19 06:01 jieter

There is little information online specially using CBVs. I found someone that implemented it successfully I will get in touch soon, since I honestly think will be a great addition to see the integration of these two amazing packages.

AndreGuerra123 avatar Jan 05 '19 00:01 AndreGuerra123

@AndreGuerra123 Would you be able to provide a link to the example to which you're referring? I had a quick look around and was unable to find it.

Asday avatar Mar 03 '19 06:03 Asday

I've got this working, but not sure if it's the right solution or a bit hacky...

from haystack.generic_views import SearchView
import django_tables2
from .tables import SearchTable

class MySearchView(django_tables2.SingleTableMixin, SearchView):
    table_class = SearchTable
    template_name = "search/mytemplate.html"

    def get_table_data(self):
        return [result.object for result in self.queryset]

jmb avatar Oct 07 '19 16:10 jmb