I have a django app and I want to color some text, if that text is true in dictionary.
So I have this method:views.py
def data_compare2(request):
template = get_template("main/data_compare.html")
dict2 = {"appel": 3962.00, "waspeen": 3304.07, "ananas":24}
context = {"dict2": dict2}
res = dict((v,k) for k,v in dict2.items())
return HttpResponse(template.render(context, request, res[3962.00]))
and this is the template:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="container center">
{% for key, value in dict1.items %}
{%if {{res}} %}
<div style="background-color:'red'"></div>
{%endif%}
{{ key }} {{value}}<br>
{% endfor %}
</div>
</body>
</html>
So the text appel": 3962.00 has to appear in red.
Question: how to make the founded text in dictionary red?