django – haystack.exceptions.SearchBackendError:在任何sear
发布时间:2020-12-20 13:33:17 所属栏目:Python 来源:网络整理
导读:我试图用嗖嗖声实施Haystack. 我一直收到这个错误,虽然一切似乎都配置得很好.我收到错误: haystack.exceptions.SearchBackendError: No fields were found in any search_indexes. Please correct this before attempting to search. …当我尝试做./manage.
我试图用嗖嗖声实施Haystack.
我一直收到这个错误,虽然一切似乎都配置得很好.我收到错误: haystack.exceptions.SearchBackendError: No fields were found in any search_indexes. Please correct this before attempting to search. …当我尝试做./manage.py rebuild_index 组态: HAYSTACK_SITECONF = 'myproject' HAYSTACK_SEARCH_ENGINE = 'whoosh' HAYSTACK_WHOOSH_PATH = cwd + '/whoosh/mysite_index' 在我的项目的根文件夹中成功创建了whoosh / mysite_index目录. * search_sites.py * import haystack haystack.autodiscover() * search_indexes.py * from haystack.indexes import * from haystack import site from myproject.models import * class ResearchersIndex(SearchIndex): text = CharField(document=True,use_template=True) name = CharFIeld(model_attr='name') class SubjectIndex(SearchIndex): short_name = CharField(model_attr='short_name') name = CharField(model_attr='name') text = CharField(document=True,use_template=True) class ResearchIndex(SearchIndex): text = CharField(document=True,use_template=True) abstract = TextField(model_attr='abstract') methodology = TextField(model_attr='methodology') year = IntegerField(model_attr='year') name = CharField(model_attr='name') class Graph(SearchIndex): text = CharField(document=True,use_template=True) explanation = TextField(model_attr='explanation') type = CharField(model_attr='type') name = CharField(model_attr='name') site.register(Researchers,ResearchersIndex) site.register(Subject,SubjectIndex) site.register(Research,ResearchIndex) site.register(Graph,GraphIndex) 谢谢 解决方法
问题出在您的HAYSTACK_SITECONF中.它必须是search_sites文件的路径.解决这个问题,它应该工作.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |