I want to pass a variable to django template tag dynamically but I could not succeed.
<input id="country" />
<div id="button"> Button </div>
$('#button').click(function(){
var dynamicVar=$('#country').val();
var tags= {
source: {% url myView dynamicVar %} /* but {% url myView 'someValue' %} works */
select: function(event, s){
$("#city").val(s.label);
};
$("#city").autocomplete(tags);
});
I am getting this NoReverseMatch error, saying the dynamicVar is not passed.
The long story: I am trying to get 2 cascaded dropdown lists. User selects a country, then City input becomes available. I want city field to be auto-completed field. Currently, without country field, it works but the query is slow. So I want to pre-filter it.