I have dict with hyderlink, example :
data = [{a:<\a href="http://someexample.com/a">a</a>,
b:'<\a href="http://someexample.com/b">b</a>'}]
Note : here i have add /a href because stack overflow takes it has hyperlink
if i want to output this in html , it displays a normal html text instead of hyperlink
template
<table>
{% for fetch in data %}
<tr>
<td>{{ fetch.a }}</td>
<td>{{ fetch.b }}</td>
</tr>
{% endfor %}
</table>
it gives output like html text instead of hyperlink
- <\a href="http://someexampl开发者_Python百科e.com/a">a
- <\a href="http://someexample.com/b">b
any help it really appreciate it.
Instead of storing the entire anchor tag, you should be storing just the URL (using URLField if you're storing it in a model), and then include it in your template as follows:
<table>
{% for fetch in data %}
<tr>
<td><a href="{{ fetch.a }}">{{ fetch.a }}</a></td>
<td><a href="{{ fetch.b }}">{{ fetch.b }}</a></td>
</tr>
{% endfor %}
</table>
This is happening because of automatic string escaping in the template engine. You can prevent escaping with the safe filter, like:
<table>
{% for fetch in data %}
<tr>
<td>{{ fetch.a|safe }}</td>
<td>{{ fetch.b|safe }}</td>
</tr>
{% endfor %}
</table>
精彩评论