Django:在模板中查找字符串

时间:2017-05-10 23:00:49

标签: python django django-templates

如何在另一个变量中查找django模板变量? 假设我想以{{body}}粗体出现{{search_string}},我该怎么做?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Search: {{ search_string }}</title>
</head>
<body>
    {% for title, href, body in search_list %}
        <h4><a href={{href|safe}} target="_blank"> {{ title }} </a></h4>
    {{ body }}
 <!-- I need to make occurrences of {{ search_string }} in {{ body }} bold -->
    {% endfor %}
</body>
</html>

0 个答案:

没有答案