Call django urls inside javascript on click event
问题 I got a javascript onclick event inside a template, and i want to call one of my django urls with an id parameter from it, like this : $(document).on('click', '.alink', function () { var id = $(this).attr('id'); document.location.href ="{% url 'myapp:productdetailorder' id %}" }); Course this is not working at all. Any idea ? Thanks in advance !! 回答1: You are trying to access javascript variable that is created at user click on frontend within your Django template at the backend. But, you