2011-11-07 51 views
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 haystackwhoosh我安裝的應用程序
在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. 

有一個人有什麼想法?預先感謝您可能需要提供的任何幫助。

回答

1

請注意,HAYSTACK_SITECONF文檔中顯示的值僅爲示例。真實名稱應該是定義SearchIndex派生類的模塊。所以,就你的情況而言,模塊是search_indexes,那麼你應該有HAYSTACK_SITECONF='search_indexes' 另外,關於解釋器上出現的那個錯誤,你是否使用python ./manage.py shell得到它?如果沒有,settings.py不會在解釋器中加載。

+0

抱歉回答這麼晚,但我在其他地方有點忙。我不是在使用2.0.0-alpha版本。我給我一些錯誤,我得到磨練我試圖進口乾草堆(請看看我的問題描述) – Cadilac

+0

好的,我重寫了相應的答案 –

+0

'python ./manage.py shell'我導入haystack並鍵入'>>>乾草堆.__版本___'並得到'(1,1,0)',我也定義了'HAYSTACK_SITECONF ='search_indexes'',但是這次我得到了'沒有字段在任何search_indexes中被發現。請在嘗試搜索之前糾正此問題。「這是一件困難的事情。你有什麼想法嗎? – Cadilac