How can I pass string variable in JavaScript using Django URL?

Viewed 207

This is my script:

var id = $('#filename').val();
location.href = "{% url 'officelyapp:finalTemplate' privateId=id %}"

This is my url:

path('signature/template/merge/private/access/<str:privateId>/', views.finalTemplate, name='finalTemplate')

I get the following error attached below whenever I tried to load my page.

Error Shown In Image

I find this link: https://stackoverflow.com/.../get-javascript-variables... that passes JavaScript value like this:

window.location = "{% url 'your_view_name' 1234 %}".replace(/1234/, tmp.toString());

But this only works when one specifically writes a specific integer value in it like 1234 in the above line of code.

0 Answers
Related