Hey Joe, There was a spelling mistake :D i've been sitting so long on this and didn't saw it
W dniu czwartek, 9 maja 2019 22:35:12 UTC+2 użytkownik Krystian napisał: > > Hi there, > > I was trying today just for myself learning to get data from google books > api https://www.googleapis.com/books/v1/volumes/ without needed auth key > but the point is that I'm getting no results. I've tried with single book > (like below), tried to get books that title contains "something" but django > is giving me key errors when I'm trying to display it on view. Could you > please tell me how to make this work with Django? I know it should be > simple but still gettings those errors > > Exception Type: KeyError > Exception Value: > > 'title' > > > import requests > > def api(request): > response = requests.get(' > https://www.googleapis.com/books/v1/volumes/YyXoAAAACAAJ') > book = response.json() > return render(request, 'books/api.html', { > 'title': book['title'], > 'authors': book['authors'] > }) > > and here is html > > {% block content %} > <h2>Google books API</h2> > <form method="get"> > <input type="text" name="book"> > <button type="submit">search on google books api</button> > </form> > {% if book %} > <p> > <strong>{{ book.title }} {{ book.authors }} > </p> > {% endif %} > {% endblock %} > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/80947a41-b83f-4859-8a95-4cb4f441dd28%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

