[Django]-Django – Escaping quotes in a template

10👍

You can just use double quotes around the “P”, because the Django {% escape prevents the embedded double quote from closing the quotes for the HTML attribute.

<tr onclick="window.location.href='{% url cpm.contacts.views.contact_details "P" c.pk %}'">
👤tom

-2👍

maybe just create a simple jQuery / JS method to change window location and put it ina seperate JS file ?

function change_location(location){
    window.location = location;
}

and use it like:

<tr onclick="change_location({% url cpm.contacts.views.contact_details 'P' c.pk %});">
👤Amyth

Leave a comment