我想使用草垛,但我所有的模型都有“body”作为它们的文本字段名称。但所有型号都是一样的。如何更改文档的名称= Django中Haystack的True字段?
现在我得到这个错误:
All 'SearchIndex' classes must use the same 'text' fieldname for the 'document=True' field. Offending index is '<qna.search_indexes.QuestionIndex object at 0x2435328>'.
这就是索引文件:
进口日期时间 从草垛进口指数 从qna.models导入问题
class QuestionIndex(indexes.SearchIndex, indexes.Indexable):
subject = indexes.CharField(document=False, use_template=False)
body = indexes.CharField(document=True, use_template=True, model_attr='user')
pub_date = indexes.DateTimeField(model_attr='pub_date')
def get_model(self):
return Question
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
它是只有一个!什么是冒犯?据我所知,字段名称不必是“文本”,它只需要在每个字段上都是相同的。但它是唯一的领域!我必须更改一些配置吗?这可能是什么原因???