简体   繁体   中英

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. 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. I also don't get import errors when I run "import haystack" so it does exist. 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 '". I get a similar error if I try haystack.management : it has no management attribute.

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').

  1. Do you have the path to haystack in your Python path? (Either the PYTHONPATH shell variable or the sys.path Python list.)

  2. Did you run python manage.py syncdb ?

  3. Does python manage.py shell followed by import haystack work?

  4. After import haystack , what do you get for haystack.__version__ ?

  5. In the same shell, type the following. 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. You can use 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). To use django-haystack check out the v1. source .

It compiles and installs simply with

python setup.py build
python setup.py install

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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