HTML escaping transforms characters with special meaning in HTML into representations displayed as text instead of interpreted as markup. Django automatically escapes template variables when templates load through the configured rendering engine. section 3.7
Test escaping in a Django template
Create a template containing “I love the sound a {{ instrument }} makes.” Rendering it with “tuba > baritone” produces “tuba > baritone.” A value such as “<b>sax</b>” becomes “<b>sax</b>,” so the tags appear as text. The Django REPL can load the file through Engine.get_default() and get_template().
Escaping is enabled by default, but trusted markup can bypass it with the safe filter or mark_safe(). format_html() creates formatted safe output; use these only when the markup is intentionally safe. section 3.7


