To perform HTML decoding/encoding using Python Django, we can use escape and unescape.
For instance, we write
from html import escape
print(escape("<"))
to escape the '<' string.
And we reverse the escaping with
from html import unescape
print(unescape(">"))
to call unescape to unescape the ">" string.