I have table data in PostGreSQL which is easily accessed in my Django View. Now I want to pass this data to a javascript .js file whose purpose is to use this data and visualize using d3.js
This is what I have tried as an example, but no luck
views.py
def view_function(request):
data = 'test_data'
return render(request, 'test.html', context = {'data':data})
test.html
<head>
</head>
<body>
<script src="{% static 'test.js' %}">myFunction({{data}})</script>
</body>
test.js
function myFunction(view_data) {
console.log(view_data);
}