kwk9892
kwk9892

Reputation: 120

How to avoid escape for Django tags in HTML

I'm reading an entire page's content from database and render them in a HTML file. Here are some examples. In database:

<a href="{% url 'home_view' %}></a>

In order to avoid escape of HTML tags, I use {{ page.content|safe }} But I couldn't render {% url 'home_view' %}

Upvotes: 2

Views: 176

Answers (1)

mrzrm
mrzrm

Reputation: 936

You can control auto-escaping behavior using autoescape template tag. In your case, you can use the below snippet.

{% autoescape off %}{{ page.content }}{% endautoescape %}

You can get more information in autoescape Documentation

Upvotes: 1

Related Questions