在用Haystack 2.4.1(Django 1.8)享受我的第一個結果的同時,我不得不承認我很難學習它。這些文檔有時是不完整的,有些功能只有幾個例子。Haystack Faceted:__init __()得到了一個意想不到的關鍵字參數'facet_fields'
分面搜索就是其中之一。
我正在關注的documentation,並在url.py:
urlpatterns = patterns('haystack.views',
url(r'^$', FacetedSearchView(form_class=FacetedSearchForm, facet_fields=['author']), name='haystack_search'),
)
,我發現了以下錯誤:
TypeError at /tag_analytics/faceted_search/
__init__() got an unexpected keyword argument 'facet_fields'
貌似FacetSearchView不接受facet_fields
參數,這把我帶到2.4.0版本,當正確的方式做到這一點是
FacetedSearchView(form_class=FacetedSearchForm, searchqueryset=sqs)
雖然我敢肯定,我的版本是2.4.1,我試過這個選項,並提前獲得了
TypeError at /tag_analytics/faceted_search/
slice indices must be integers or None or have an __index__ method
感謝任何線索!
最好, 艾倫
我有一個「解決方案」,我懷疑是正確的,因爲這意味着文檔是完全錯誤的。無論如何,在url.py我用'FacetedSearchView.as_view(form_class)'從'haystack.views'導入FacetedSearchView'從'haystack.generic_views導入FacetedSearchView'和'FacetedSearchView(form_class = FacetedSearchForm,facet_fields = ['author']) = FacetedSearchForm,facet_fields = ['author'],template_name ='search.html',context_object_name ='page_object')'。它有效,但我仍然想要了解問題所在! –