2012-07-11 97 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