def search_googlex(request): """ Searches google books for a book with the given barcode (isbn) """ if request.method == 'POST': form = BookSearch(request.POST) barcode = form.data['barcode'] response = google_books.search(barcode) print "I passed the loop" if request.is_ajax(): print "I think I am ajax" json = simplejson.dumps(response) return HttpResponse(json, mimetype='application/json') return render(request, 'search.html', {'book_list': response['book_list'], 'form': form, 'title' :'Search Google'}) else: book = Book(author='a', title='t') book.id = 'dummy' form = BookSearch() return render(request, 'search.html', {'form': form, 'title' : 'Search Google', 'book_list' : [book]},)
def search_googlex(request): """ Searches google books for a book with the given barcode (isbn) """ if request.method == 'POST': form = BookSearch(request.POST) barcode = form.data['barcode'] response = google_books.search(barcode) print "I passed the loop" if request.is_ajax(): print "I think I am ajax" json = simplejson.dumps(response) return HttpResponse(json, mimetype='application/json') return render( request, 'search.html', { 'book_list': response['book_list'], 'form': form, 'title': 'Search Google' }) else: book = Book(author='a', title='t') book.id = 'dummy' form = BookSearch() return render( request, 'search.html', { 'form': form, 'title': 'Search Google', 'book_list': [book] }, )