我对 django haystack 完全陌生,我在开始使用它时遇到了麻烦。
当我搜索时出现错误
Failed to query Solr using '*:*': [Reason: Error 400 undefined field django_ct]
当我重建索引时出现此错误
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'. Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
All documents removed.
ERROR:root:Error updating votingapp using default
Traceback (most recent call last):
...
...
index_qs = self.index_queryset(using=using)
TypeError: index_queryset() got an unexpected keyword argument 'using'
我已经建立了一个简单的索引类
class QuestionsIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
qs = indexes.CharField(model_attr='question')
def get_model(self):
return Questions
def index_queryset(self):
return self.get_model().objects.all()
在 settings.py 中添加代码
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr'
# ...or for multicore...
# 'URL': 'http://127.0.0.1:8983/solr/mysite',
},
}
添加了网址
url(r'^search/', include('haystack.urls')),
查看代码
def home(request):
if request.method == "POST":
print SearchQuerySet().all()
return render_to_response('search.html',{})
请告知我在哪里做错了