I have a small js script that I would like to put in a separate js file:
function user_click(sender, e){ var addressee = sender.id.substring(3); if(sender == e.target){ var base_url = "{% url 'user' 0 %}"; base_url = base_url.replace('0', addressee); document.location.href = base_url; } else{ var data = 'id=' + addressee; POST_AJAX(data, '{% url 'to_man' %}'); } }
The trouble is that if I place it in a separate file in the static directory, as recommended by django, the magic of templates stops working: in particular, the url tag. Maybe, who knows any jango extensions that can render js-files from the static folder?
onclick="user_click({% url 'user' 0 %})"
- Andrey