我已经阅读了这两个构建搜索应用程序的教程。
但是当我醒过来的时候:
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)
我收到这个错误(当我也尝试导入 haystack 时):
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中导入haystack,报错:
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 安装了 haystack。
我的 django 版本:1.4
更新:
如果你在导入haystack的时候遇到类似这样的错误:
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
尝试将您的项目导入为 ./manage.py shell 而不是 import haystack。
请您参考如下方法:
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
否则,只需下载“master”分支压缩包并使用 python setup.py install 手动安装。
