is it possible to highlight a rendered text?

21 views
Skip to first unread message

dot...@gmail.com

unread,
Apr 5, 2017, 12:23:17 PM4/5/17
to django-haystack

I'm new to haystack (and also relatively new to django) and my approach to follow tutorials and examples and mix them to obtain the wanted result.

I defined indexes for my models and I defined a <model>_text.txt template for each of them.

Then, following some example, in my search_indexes.py I added a line like this
        rendered = indexes.CharField(use_template=True, indexed=False)
Then I defined a <modelname>_rendered.txt template where I put HTML tags to render the index output.

Although I have no idea of what good or bad is this solution, it works for my case: I put
        {{ result.rendered | safe }}
in the search template and get the formatted results.

The problem comes if I want to highlight results.
I thought I could "highlight" rendered text but it looks like is not possible. The following
          {% with qaz=result.rendered|safe %}
            {% highlight qaz with query %}
          {% endwith %}
returns a string with html tags stripped.

Any idea?

Alberto
Reply all
Reply to author
Forward
0 new messages