Im trying to have a dynamic url dispatcher such as:
"{% url 'url_name' 'variable' %}" where variable is set dynamically within my javascript.
What I want to do is basically redirect to a different page when a <select> value is changed.
$(document).ready(function() {
$('#select').change(function() {
var id = $('#select').val();
window.location.replace("{% url 'url_name' 'id' %}");
});
});
I can't do it with a simple string concat as such:
"{% url 'url_name' '" + id + "' %}" as it returns this error Reverse for 'url_name' with arguments '('" + id + "',)' not found.
The select itself is being filled with backend data:
<select id="select">
{% for item in list %}
<option value="{{item.id}}">{{item.name}}</option>
{% endfor %}
</select>
I cant figure out what the syntax for this is.