我已閱讀這兩個教程,用於構建搜索應用程序。Ubuntu - Django Solr和Haystack集成錯誤
但是當我來到:
Configure django-haystack, set up the search index classes according to the docs
http://docs.haystacksearch.org/dev/tutorial.html#configuration
Add the required solr fields to settings.py (solr server location)
我得到這個錯誤(當試圖導入乾草堆時......)
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.
在python錯誤導入乾草堆:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/django_haystack-1.2.7-py2.6.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.
我已經安裝了草堆與sudo easy_install https://github.com/toastdriven/django-haystack/zipball/v1.2.7
。
我的Django的版本:1.4
UPDATE:
,如果你有麻煩某事像這樣的錯誤導入乾草堆時:
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
嘗試在你的項目中導入爲./manage .py shell比進口乾草堆....
你掛斷了什麼?您是否在settings.py中定義了'HAYSTACK_SITECONF'? – 2012-07-11 14:49:53
@chriss我沒有定義HAYSTACK_SITECONF我已經定義HAYSTACK_CONNECTIONS,而是。因爲安裝Haystack 1.2.7。 – Aragon 2012-07-11 14:52:40
Haystack 1.2.7不使用'HAYSTACK_CONNECTIONS' - 即Haystack 2.0+。 Haystack文檔默認爲開發版本,而不是當前的PyPi版本。儘管如此,如果您想要走這條路線,Haystack 2.0是完全可用的。我自己使用它。你只需要從Github克隆它。 – 2012-07-11 14:59:05