我得到“无”的拼写建议。
首先,我在我的 settings.py 文件中有这个设置:
HAYSTACK_INCLUDE_SPELLING = True
我已经重建了索引:
python manage.py rebuild_index
并对其进行了很好的更新
python manage.py update_index
搜索工作正常。当我搜索“充电器”时,它会返回匹配的结果。所以在我的views.py中,我尝试了:
from haystack.query import SearchQuerySet
def testpage(request):
test_results = SearchQuerySet().auto_query('Chargr')
spelling_suggestion = test_results.spelling_suggestion()
return render_to_response('testpage.html', {
'test': test_results,
'spelling_suggestion': spelling_suggestion
})
但是,我的模板:
<html>
<body>
{{ test }}<p>
{{ spelling_suggestion }}
</body>
</html>
仍然没有返回:
[]
None
显然,我对 {{ test }} 没有任何期望,但我不应该为 {{ spelling_suggestion }} 得到一些东西吗?我错过了什么?