gpt4 book ai didi

带有嗖嗖声的 Django 干草堆

转载 作者:行者123 更新时间:2023-12-02 04:05:17 25 4
gpt4 key购买 nike

我正进入(状态SearchBackendError at /forum/search/
No fields were found in any search_indexes. Please correct this before attempting to search.

search_indexes放在 djangobb应用根目录:

from haystack.indexes import *
from haystack import site

import djangobb_forum.models as models

class PostIndex(RealTimeSearchIndex):
text = CharField(document=True, use_template=True)
author = CharField(model_attr='user')
created = DateTimeField(model_attr='created')
topic = CharField(model_attr='topic')
category = CharField(model_attr='topic__forum__category__name')
forum = IntegerField(model_attr='topic__forum__pk')

site.register(models.Post, PostIndex)

设置.py
# Haystack settings 

HAYSTACK_SITECONF = 'search_sites'
HAYSTACK_SEARCH_ENGINE = 'whoosh'
HAYSTACK_WHOOSH_PATH = os.path.join(PROJECT_ROOT, 'djangobb_index')

我也有 haystackwhoosh在我安装的应用程序中。
在 python 解释器中:
>>> import haystack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/.../lib/python2.7/django_haystack-1.2.5-py2.5.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.

有人有什么想法吗?提前感谢您可能需要提供的任何帮助。

最佳答案

请注意,文档中显示的 HAYSTACK_SITECONF 的值只是一个示例。真实名称应该是定义 SearchIndex 派生类的模块。所以,在你的情况下,模块是 search_indexes,那么你应该有 HAYSTACK_SITECONF='search_indexes'另外,关于解释器中出现的错误,您是否使用 python ./manage.py shell 得到它? ?如果不是,则设置.py 没有在解释器中加载。

关于带有嗖嗖声的 Django 干草堆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8036715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com