2012-07-11 79 views
2

我已閱讀這兩個教程,用於構建搜索應用程序。Ubuntu - Django Solr和Haystack集成錯誤

  1. 安裝Solr的和在Ubuntu與OpenJDK的Django的草垛,here
  2. Django的 - 草堆 - Solr的 - 安裝指南,here

但是當我來到:

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比進口乾草堆....

+0

你掛斷了什麼?您是否在settings.py中定義了'HAYSTACK_SITECONF'? – 2012-07-11 14:49:53

+0

@chriss我沒有定義HAYSTACK_SITECONF我已經定義HAYSTACK_CONNECTIONS,而是。因爲安裝Haystack 1.2.7。 – Aragon 2012-07-11 14:52:40

+0

Haystack 1.2.7不使用'HAYSTACK_CONNECTIONS' - 即Haystack 2.0+。 Haystack文檔默認爲開發版本,而不是當前的PyPi版本。儘管如此,如果您想要走這條路線,Haystack 2.0是完全可用的。我自己使用它。你只需要從Github克隆它。 – 2012-07-11 14:59:05

回答

3

Haystack 1.2.7不使用HAYSTACK_CONNECTIONS;只有Haystack 2.0+使用該設置。 Haystack文檔默認爲開發版本(當前爲2.0.0-beta),而不是當前的PyPi版本(1.2.7),因此您需要小心所查看的文檔的版本。

但是,如果您想要走那條路線,Haystack 2.0.0-beta是完全可用的。我自己使用它。你只需要從Github克隆它。最簡單的方法是使用PIP:

pip install git+https://github.com/toastdriven/django-haystack.git#egg=django-haystack 

否則,只需下載「主人」分支壓縮包的用python setup.py install手動安裝。

+0

謝謝你克里斯 – Aragon 2012-07-11 16:16:50