我正在尝试在 django sphinx 中使用 BuildExcerpts。我的观点是这样的:
q = request.GET.get('q', '')
my_model_list = MyModel.search.query(q).set_options(passages=True, passages_opts={
'before_match':"<font color='red'>",
'after_match':'</font>',
'chunk_separator':' ... ',
'around':6,
})
当我运行这个时,我得到一个AssertionError
这是跟踪:
Traceback:
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "C:\django\myproject\myapp\views.py" in home_page
81. my_model_list = remove_duplicates(list(my_model_list))
File "c:\python25\lib\site-packages\django_sphinx-2.2.3-py2.5.egg\djangosphinx\models.py" in __iter__
243. return iter(self._get_data())
File "c:\python25\lib\site-packages\django_sphinx-2.2.3-py2.5.egg\djangosphinx\models.py" in _get_data
422. self._result_cache = list(self._get_results())
File "c:\python25\lib\site-packages\django_sphinx-2.2.3-py2.5.egg\djangosphinx\models.py" in _get_results
603. r['passages'] = self._get_passages(queryset[r['id']], results['fields'], words)
File "c:\python25\lib\site-packages\django_sphinx-2.2.3-py2.5.egg\djangosphinx\models.py" in _get_passages
657. passages_list = client.BuildExcerpts(docs, self._index, words, opts)
File "C:\Python25\lib\site-packages\django_sphinx-2.2.3-py2.5.egg\djangosphinx\apis\api278\__init__.py" in BuildExcerpts
791. assert(isinstance(doc, str))
Exception Type: AssertionError at /
Exception Value:
我不确定发生了什么。有人有这方面的经验吗?
我正在使用 django 1.2.3、Sphinx 0.9.9 和 django-sphinx 2.2.3。