1

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);
}
2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.