I passed personal information in js file using views.py. So, In the js file, I added the Django template for loop to iterate the personal information and pass the javascript function. but it's not working for me. I am new in this concept.
View file
def sample(request):
p=[]
p.append({name:santhosh, age:20},name:kumar, age:21})
return render(request, 'index.js',{'p':p})
index.js
{% for i in p %}
var data = load_html(i)
{% endfor %}
function load_html(i){
return '<h1>{{ i.name }}</h1>'
}
This is my sample code. I tried to pass (i value in load_html()) function. but it cannot pass the value in that function. How to pass value and get name.