Get your own Django server Result Size: 625 x 565
template.html
views.py
 
<!DOCTYPE html>
<html>
<body>

<h3>Without escapejs:</h3>
<button onclick="alert('{{ var1 }}')">Click me</button>

<h3>With escapejs:</h3>
<button onclick="alert('{{ var1|escapejs }}')">Click me</button>

<p>Try clicking both buttons. The JavaScript without the escapejs filter will raise an error.

<p>In views.py you can see what the var1 variable looks like.</p>

</body>
</html>                  
127.0.0.1:8000/testing