干草堆/ Whoosh索引生成错误 [英] Haystack / Whoosh Index Generation Error

查看:99
本文介绍了干草堆/ Whoosh索引生成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Whoosh后端设置干草堆。当我尝试生成索引[或与此有关的任何索引命令]时,我收到:

I'm trying to setup haystack with whoosh backend. When i try to gen the index [or any index command for that matter] i receive:

TypeError: Item in ``from list'' not a string

如果我完全删除了我的search_indexes.py,则会收到相同的错误[因此我猜它根本找不到该文件]

if i completely remove my search_indexes.py i get the same error [so i'm guessing it can't find that file at all]

什么可能导致此错误?它设置为自动发现,并且我确定我的应用已安装,因为我当前正在使用它。

what might cause this error? it's set to autodiscover and i'm sure my app is installed because i'm currently using it.

完整追溯:

    Traceback (most recent call last):
  File "./manage.py", line 17, in <module>
    execute_manager(settings)
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/core/management/__init__.py", line 362, in execute_manager
    utility.execute()
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/core/management/__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/core/management/__init__.py", line 257, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/core/management/__init__.py", line 67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Users/ghostrocket/Development/Redux/.dependencies/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/ghostrocket/Development/Redux/.dependencies/haystack/__init__.py", line 124, in <module>
    handle_registrations()
  File "/Users/ghostrocket/Development/Redux/.dependencies/haystack/__init__.py", line 121, in handle_registrations
    search_sites_conf = __import__(settings.HAYSTACK_SITECONF)
  File "/Users/ghostrocket/Development/Redux/website/../website/search_sites.py", line 2, in <module>
    haystack.autodiscover()
  File "/Users/ghostrocket/Development/Redux/.dependencies/haystack/__init__.py", line 83, in autodiscover
    app_path = __import__(app, {}, {}, [app.split('.')[-1]]).__path__
TypeError: Item in ``from list'' not a string

这是我的search_indexes.py

and here is my search_indexes.py

from haystack import indexes
from haystack import site
from myproject.models import *

site.register(myobject)


推荐答案

似乎您遇到了两个问题。

It seems like there are two problems you're running into.

第一个是生成 TypeError 的那个。当Haystack正在搜索您在 INSTALLED_APPS 中列出的每个应用中搜索search_indexes.py时,就会发生这种情况(因为您正在自动注册)。我不确定是什么问题,但首先要从您的项目中搜索列表中的 ,然后仔细检查您的代码。我以前从未遇到过该异常,但是如果您编写的代码中发生了这种情况,则应该在问题中张贴任何相关的部分

The first is the one that's generating that TypeError. It occurs while Haystack is searching through each app you have listed in INSTALLED_APPS for a search_indexes.py (since you're auto-registering). I'm not sure exactly what the problem is, but I'd start by doing a search through your project for from list and double-checking your code. I haven't encountered that exception before, but if that's happening in code you wrote you should post any relevant sections in your question

我相信您会收到相同错误的原因有或没有search_indexes.py文件的原因是,它永远不会达到尝试执行该文件中代码的地步。

I believe the reason you get the same error with or without the search_indexes.py file is because it never reaches the point of trying to execute the code in that file.

也就是说,应该会发生更多的事情文件(这是第二个问题)。您必须创建一个索引类(继承自haystack.indexes.SearchIndex),然后将其注册到模型中。有关说明和示例,请参见本节

That said, there should be more happening in that file (which is the second problem). You have to create an index class (that inherits from haystack.indexes.SearchIndex) and register that with the model. See this section of the documentation for instructions and an example.

我也会在 django-haystack Google中问这个问题分组,因为干草堆的作者和其他用户会在此处看到它们,并且他们往往会非常有帮助。

I'd also ask this question in the django-haystack Google Group since the author and other users of haystack will see it there and they tend to be extremely helpful.

这篇关于干草堆/ Whoosh索引生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆