How to display json value in django template?
<p>This is my View.py code... </p>

<pre><code>import requests 
from django.http import HttpResponse 
from django.shortcuts import render import json 
def book(request):
    if request.method == 'POST':
        r = requests.post('http://api.railwayapi.com/cancelled/date/01-09-2016/apikey/mezxa1595/', params=request.POST)
        book=r.json()
    else:
        r = requests.get('http://api.railwayapi.com/cancelled/date/01-09-2016/apikey/mezxa1595/', params=request.GET)
        book=r.json()
        js=json.dumps(book)
    if r.status_code == 200:
        return render(request,'book.html', {'js':js})
    return HttpResponse('Could not save data')
</code></pre>

<p>and question is that how to display <code>return render(request,'book.html', {'js':js})</code> in Html?</p>

<p>That "js" should be a python dict not json object. You may need to:</p>

<pre><code>return render(request,'book.html', {'js': json.loads(js)})
</code></pre>

<p>Then you can use the variables in <code>book.html</code> template.</p>

javascript python json django