4👍
✅
One hacky way to do it would be to include following script in your template that references the javascript file.
<script>
var fun_url = "{% url 'namespace: view_fun' %}";
</script>
And then expecting this fun_url
variable in your referenced javascript file.
Source:stackexchange.com