简体   繁体   English

安装django-haystack

[英]Installing django-haystack

Super simple question: I went through the "getting start" doc for haystack (using whoosh; I installed both python-whoosh and haystack using pip (first time using it)), and I simply cannot run python manage.py rebuild_index. 超级简单的问题:我经历了干草堆的“开始”文档(使用嗖!我使用pip安装了python-who和haystack(第一次使用它)),我根本无法运行python manage.py rebuild_index。 I get this error: 我收到此错误:

python manage.py rebuild_index
Unknown command: 'rebuild_index'
Type 'manage.py help' for usage

I do have 'haystack' listed in my INSTALLED_APPS in settings.py, so this solution doesn't seem to work for me. 我在settings.py的INSTALLED_APPS中列出了'haystack',所以这个解决方案对我来说似乎不起作用。 I also don't get import errors when I run "import haystack" so it does exist. 我运行“import haystack”时也没有导入导入错误,所以它确实存在。 I tried this on my existing project as well as a brand new object made just for this and I just can't get it to work. 我在我现有的项目上尝试了这个,以及为此而制作的一个全新的对象,我无法让它工作。

However, when I import haystack after python manage.py shell and try haystack.__version__ I get "AttributeError: 'module' object has no attribute ' version '". 但是,当我在python manage.py shell之后导入haystack并尝试haystack.__version__我得到“AttributeError:'module'对象没有属性' version '”。 I get a similar error if I try haystack.management : it has no management attribute. 如果我尝试haystack.management我会收到类似的错误:它没有管理属性。

It must be something super simple I'm missing. 它一定是超级简单的东西,我很想念。 Thank you for reading this! 谢谢您阅读此篇!

Did you perhaps install the wrong thing? 你有没有安装错误的东西? This (embarrassingly) happend to me just today. 这件事(令人尴尬)就在今天发生在我身上。 Make sure you install 'django-haystack' and not just 'haystack' (and you will have to remove 'haystack', since it conflicts with 'django-haystack'). 确保你安装'django-haystack'而不仅仅是'haystack'(你必须删除'haystack',因为它与'django-haystack'冲突)。

  1. Do you have the path to haystack in your Python path? 你有Python路径中的haystack路径吗? (Either the PYTHONPATH shell variable or the sys.path Python list.) PYTHONPATH shell变量或sys.path Python列表。)

  2. Did you run python manage.py syncdb ? 你运行python manage.py syncdb吗?

  3. Does python manage.py shell followed by import haystack work? python manage.py shell后跟import haystack工作吗?

  4. After import haystack , what do you get for haystack.__version__ ? import haystack ,你得到了什么haystack.__version__

  5. In the same shell, type the following. 在同一个shell中,键入以下内容。 Do you get errors for any of them? 你有没有错误?

    • haystack.management.commands
    • haystack.management.commands.rebuild_index
    • haystack.management.commands.rebuild_index.Command.help

I had the same error that you did, and fixed it by removing the old .egg and installing directly from the latest version. 我遇到了同样的错误,并通过删除旧的.egg并直接从最新版本安装来修复它。 You can use easy_install: 你可以使用easy_install:

easy_install https://github.com/toastdriven/django-haystack/zipball/v1.2.4

Hope this helps! 希望这可以帮助!

我刚遇到同样的问题,并且没有在settings.py中设置HAYSTACK_SITECONF。

而不是使用python manage.py rebuild_index尝试使用./manage.py rebuild_index

只是做pip uninstall haystack

pip install django-haystack

I had the same problem - for whatever reason, the haystack version in pip is quite old and obsolete (v 0.6 as of today). 我遇到了同样的问题 - 无论出于何种原因,pip中的干草堆版本已经过时(过去的v 0.6)。 To use django-haystack check out the v1. 要使用django-haystack,请查看v1。 source . 来源

It compiles and installs simply with 它简单地编译和安装

python setup.py build
python setup.py install

Hope that helps! 希望有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM