[Answer]-Django Haystack search in Html

1๐Ÿ‘

โœ…

If i correctly understand you, all you need is to set search indexes without html tags?

We solved that problem this way:

class PostIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(model_attr='text', use_template=True, document=True)

and in template (search/indexes/blogs/post_test.html) we just used striptags filter

{{ object.content|striptags }}

After that you need to build_schema and rebuild_index. Now it search correctly without tags.

๐Ÿ‘คAndrey Nelubin

Leave a comment