My navbar lives in a base.html template which is extended by all pages. When I click a link in the navbar the active class is added but right after when I travel to that page it reverts to its previous state when only the initial page was highlighted.
Here is my base.html template
{% load static %}
<!-- DOCTYPE html -->
<html>
<head>
<title>Title</title>
<!-- new bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://use.fontawesome.com/a0c7be9623.js"></script>
<!-- css -->
<link rel='stylesheet' href='{% static "css/base.css" %}' />
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<a class="navbar-brand" href='{% url "home" %}'>Maximum Likelihood</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link active" href='{% url "home" %}'>Info<span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href='{% url "about" %}'>About</a>
<a class="nav-item nav-link" href='{% url "stuff" %}'>Stuff</a>
</div>
<div class="navbar-nav">
<a class="nav-item nav-link ml-auto" href='google.com'>Outside link</a>
</div>
</div>
</nav>
{% block content %}
{% endblock content %}
<br>
<!-- <!-- bootstrap's js stuff -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<script src='{% static "js/nav.js" %}'/></script>
</body>
Here is my nav.js
$(".nav-link").on("click", function(){
$(".nav").find(".active").removeClass("active");
$(this).addClass("active");
});