如何索引 Haystack 中的 CommentsField?
How to index CommentsField in Haystack?
我的 Django 模型中有一个 comments = CommentsField()
。我想知道如何在 Haystack 中将此 CommentsField() 类型索引为 indexes.CharField(model_attr='comments')
.
你可以,
comment = indexes.CharField(model_attr='comments')
并准备上面的评论字段,
prepare_comment(self,obj):
return obj.comment
obj.comment是评论的实际内容
有关准备的更多信息,请参阅下面的 link
http://django-haystack.readthedocs.org/en/latest/searchfield_api.html?highlight=prepare#SearchField.prepare
我的 Django 模型中有一个 comments = CommentsField()
。我想知道如何在 Haystack 中将此 CommentsField() 类型索引为 indexes.CharField(model_attr='comments')
.
你可以,
comment = indexes.CharField(model_attr='comments')
并准备上面的评论字段,
prepare_comment(self,obj):
return obj.comment
obj.comment是评论的实际内容
有关准备的更多信息,请参阅下面的 link http://django-haystack.readthedocs.org/en/latest/searchfield_api.html?highlight=prepare#SearchField.prepare