Django Haystack and Taggit

为君一笑 提交于 2019-12-03 16:31:29

To get the tags into the search index we added them to our content template file eg

{{ object.title }}
{{ object.body }}
{% for tag in object.tags.all %} {{ tag.name }} {% endfor %}
{{ object.user.get_full_name }}

We also include it as a MultiValueField

tags = indexes.MultiValueField()

def prepare_tags(self, obj):
    return [tag.name for tag in obj.tags.all()]

Haven't had success trying to make boost work in either case, but the search definitely indexes them correctly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!