3
我越來越 SearchBackendError at /forum/search/ No fields were found in any search_indexes. Please correct this before attempting to search.
Django的草垛與嗖
與search_indexes
放在djangobb
應用程序根目錄:
from haystack.indexes import *
from haystack import site
import djangobb_forum.models as models
class PostIndex(RealTimeSearchIndex):
text = CharField(document=True, use_template=True)
author = CharField(model_attr='user')
created = DateTimeField(model_attr='created')
topic = CharField(model_attr='topic')
category = CharField(model_attr='topic__forum__category__name')
forum = IntegerField(model_attr='topic__forum__pk')
site.register(models.Post, PostIndex)
settings.py
# Haystack settings
HAYSTACK_SITECONF = 'search_sites'
HAYSTACK_SEARCH_ENGINE = 'whoosh'
HAYSTACK_WHOOSH_PATH = os.path.join(PROJECT_ROOT, 'djangobb_index')
也是我在havae haystack
和whoosh
我安裝的應用程序
在Python解釋:
>>> import haystack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/.../lib/python2.7/django_haystack-1.2.5-py2.5.egg/haystack/__init__.py", line 26, in <module>
raise ImproperlyConfigured("You must define the HAYSTACK_SITECONF setting before using the search framework.")
django.core.exceptions.ImproperlyConfigured: You must define the HAYSTACK_SITECONF setting before using the search framework.
有一個人有什麼想法?預先感謝您可能需要提供的任何幫助。
抱歉回答這麼晚,但我在其他地方有點忙。我不是在使用2.0.0-alpha版本。我給我一些錯誤,我得到磨練我試圖進口乾草堆(請看看我的問題描述) – Cadilac
好的,我重寫了相應的答案 –
'python ./manage.py shell'我導入haystack並鍵入'>>>乾草堆.__版本___'並得到'(1,1,0)',我也定義了'HAYSTACK_SITECONF ='search_indexes'',但是這次我得到了'沒有字段在任何search_indexes中被發現。請在嘗試搜索之前糾正此問題。「這是一件困難的事情。你有什麼想法嗎? – Cadilac