3

スペルの提案で「なし」が表示されます。

まず、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}}に何かを取得するべきではありませんか?私は何が欠けていますか?

4

1 に答える 1

4

I did finally figure this out (with some help from the Haystack message group)

There is some detail here on configuration changes that must be made. In addition, I had to add lines to haystack's views.py file (under def extra_context):

spelling = self.results.spelling_suggestion(self.query)
return {'suggestion': spelling, . . .

Then I added {{ suggest }} to my output template

于 2011-03-15T20:07:46.897 に答える