I've wrote a custom view to parse markdown files using regex and I'm passing content as a string literal to the template
context = "Django is a web framework written using <a href='https://www.python.org/'>Python</a>"
return render(request, "blog/post.html", {"context": context})
And in template:
<p>{{ context }}</p>
But the engine renders content as a plain text. How to make links to be links and paragraphs to be paragraphs?
CodePudding user response:
Just add safe
template tag like @markwalker_ said in comments it will turn off autoescape of html tags.
<p>{{ context|safe }}</p>