Move the Javascript to its own file. Either include it with django or load it with a script tag.