9π
β
The documentation is just wrong, and confusing. You cannot pass facet_fields
to the constructor for FacetedSearchView
.
The approach you have taken is correct although rather than put all those arguments in the url
definition, you should create your own view β something like this:
# tag_analytics/views.py
from haystack.generic_views import FacetedSearchView as BaseFacetedSearchView
# Now create your own that subclasses the base view
class FacetedSearchView(BaseFacetedSearchView):
form_class = FacetedSearchForm
facet_fields = ['author']
template_name = 'search.html'
context_object_name = 'page_object'
# ... Any other custom methods etc
Then in urls.py
:
from tag_analytics.views import FacetedSearchView
#...
url(r'^$', FacetedSearchView.as_view(), name='haystack_search'),
π€solarissmoke
Source:stackexchange.com