Get javascript variable's value in Django url template tag

I found a trick that might work under most circumstances:

var url_mask = "{% url 'someview' arg1=12345 %}".replace(/12345/, tmp.toString());

It's clean, and it doesn't break DRY principle.


Just making it clear so next readers can have a comprehensive solution. In regard to the question, this is how I used Mike Lee solution for an example case which is redirecting with Javascript to a new page with a parameter in a variable named tmp:

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