停止刷新Django模板中的js文件

我用Django模板创建了倒数计时器,当HTML页面上的页面刷新数据是更新时,该模板在HTML模板上显示,但它也重置了倒数计时器。我不希望有任何方法可以停止刷新脚本或不刷新就更新数据。

app.js

var count = 8
var counter = setInterval(timer , 1000)

function timer(){
    count = count-1
    if (count <= 0)
    {
        clearInterval(counter);

        return window.location.href = urlFromDjango
    }
    document.getElementById("timer").innerHTML= count + " secs";
}

index.html

{% load static %}
<head>
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="{% static 'css/app.css' %}">
    <script src="{% static 'js/app.js' %}"></script>
</head>
<script>
    var urlFromDjango = "{% url 'app:result' %}"
</script>

<body>
     <h1 id="timer"></h1>
</body>

<h1>{{user.username}}</h1><br>
<h2>score -{{user.userextend.score}}</h2>
<form action="{% url 'app:detail' quiz_id=que.quiz.id question_id=que.id %}" method="post">
     {% csrf_token %}
     {% for choice in que.answer_set.all %}
         <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
         <label for="choice{{ forloop.counter }}">{{ choice.answer }}</label><br>
     {% endfor %}
     <button><a href="{% url 'app:detail' %}">Next</a></button>
</form>