Re: How to use Django with python-requests to fetch data from google api?

2019-05-10 Thread Joe Reitman
Krystian, I got this work by changing the template tag name variables and removing the if statement. Since 'authors' is a list, you could send the entire list to the template and do a for-loop to render all the authors. def api(request): query = request.GET response =

Re: How to use Django with python-requests to fetch data from google api?

2019-05-09 Thread Krystian
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

Re: How to use Django with python-requests to fetch data from google api?

2019-05-09 Thread Krystian
Hey, I've updated some code and now I think it should work but the problem is I guess with list book = {} def api(request): book = {} if 'book' in request.GET: book = request.GET['book'] url = 'https://www.googleapis.com/books/v1/volumes?q=%s' % book reponse =

Re: How to use Django with python-requests to fetch data from google api?

2019-05-09 Thread Krystian
Hi Joe, Thanks you for clarying :) anyway now is KeyError and i dont know why the request is wrong, should I add the "items" before? Because https://jsoneditoronline.org/ shows that this data from google books api looks like this and maybe request is wrong? object►items►0►volumeInfo►authors►

Re: How to use Django with python-requests to fetch data from google api?

2019-05-09 Thread Joe Reitman
Krystian, To extract the Title and Author from your API call you need: return render(request, 'books/api.html', { 'title': book['volumeInfo']['title'], 'authors': book['volumeInfo']['authors'][0] }) 'authors' is stored in an array(list) so if you want to pass all the

How to use Django with python-requests to fetch data from google api?

2019-05-09 Thread Krystian
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