Вы можете попробовать вот так
Определить переменную данных в файле шаблона django и получить доступ к файлу js
Здесь переменная данных в index.html доступна в файле Javascript
index.html
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<h1>hello d3</h1>
<div>
</div>
<script>
var data = '{% static "data.csv" %}'
</script>
<script type="text/javascript" src="{% static 'js/d3.js' %}">
</script>
</body>
</html>
/ статические / JS / d3.js
переменная данных передается из index.html
d3.csv(data, function (err, csv) {
console.log(csv)
});