python - 带有高亮模板标签的安全过滤器 django-haystack

标签 python django django-templates django-haystack

我正在使用 Django Haystack 在我的网站上进行搜索,但我需要使用模板过滤器 "safe" 过滤我的 TextField 的所有 html 代码并根据搜索条件突出显示搜索结果。

有没有办法做到这一点?我试过

{% highlight result.object.content|safe with query %}

但它不起作用。

最佳答案

你是不是忘记加载 {% highlight %} 模板标签了?

关于python - 带有高亮模板标签的安全过滤器 django-haystack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4838305/

相关文章:

python - Tensorflow估计器输入函数: defining each feature or not?

python - 在 Python 中使用空格字符作为分隔符将句子分成单词

python - IPython.html.widgets 在 IPython 中说 : no module named widgets

python - 标准化 scipy.ndimage.filters.correlate

django - Nginx 包括来自 conf.d 的 conf 但仍加载默认设置

django - 在 PyCharm 中更改 django 应用程序目录

使用redis的非orm的django tastypie不返回任何对象

Django - 使用模板标签渲染许多模板非常慢

python - 如何制作复选框、Python、Django 的表单处理程序

django ajax/jquery 文件上传