[Python] Unable to launch json file on index.html

Discussão em 'Python' iniciado por Stack, Agosto 23, 2025.

  1. Stack

    Stack Membro Participativo

    views.py

    from django.shortcuts import render
    from django.http import HttpResponse
    import json
    booksData = open(
    r'C:\Users\Dhiraj Subedi\Desktop\pool1\books.json').read()
    data = json.loads(booksData)
    def index(request):
    context = {'books': data}
    return render(request, 'books\index.html', context)


    index.html

    <html>

    <head>
    <title></title>
    </head>

    <body>
    {% for book in books %}

    <p>{{book.title }} </p>
    <img src="{{book.url}}" width="200px">

    {% endfor %}
    </body>

    </html>


    I am not able to launch a JSON data on the index.html file and the image is not shown but its icon is seen and Books text is display there is no any Book text

    Continue reading...

Compartilhe esta Página