我是在一个应用程序和它的完美使用Hay堆栈。它是索引所有我需要的东西。但是,现在我创建了另一个具有不同模型和内容的应用程序,我想要对它进行Hay堆栈索引。这个想法是在我的网站上创建两个不同的“搜索”链接,每个应用程序一个。
但是,当我将第二个配置添加到草堆索引中时,我会遇到一些问题.
我创建了一个新的search_index.py (在我的新应用程序中),内容如下:
import datetime
from haystack.indexes import *
from haystack import site
from oportunity.models import Oportunity
class OportunityIndex(SearchIndex):
title = CharField(document=True, use_template=True)
body = CharField()
date= DateTimeField()
def index_queryset(self):
return Oportunity.objects.filter(date=datetime.datetime.now())
site.register(Oportunity, OportunityIndex)但是,当我运行python manage.py rebuild_index时,会得到以下错误:
第94行,在all_searchfields引发SearchFieldError(“所有带有'document=True‘的SearchIndex字段都必须使用相同的字段名”)。haystack.exceptions.SearchFieldError:所有带有“document=True”的SearchIndex字段都必须使用相同的字段名。
https://stackoverflow.com/questions/8965775
复制相似问题