I am doing my django project and I cannot find answer to how can I call my site from javascript function.
var time = 5;
setInterval(function() {
if(time > 0) {
document.getElementById("timecounter").innerHTML = "You will be redirected in "
+ time + " seconds. If not then ";
time--;
} else {
location.href="{% url 'index' %}"
}
},1000)
this location.href redirects to wrong place. It literally puts "{% url 'index' %}" in URL.
Thank you for help!
{% url(obviously) won't work unless it is used in a Django view/template. Use absolute URL of your site instead./