-1
request.GET ['q'], request.GET中( 'q'),和request.GET中( 'q')。謝謝request.GET ['q'],request.GET('q')和request.GET('q',)
def search(request):
if 'q' in request.GET and request.GET['q']:
q=request.GET['q']
books=Book.objects.filter(title__icontains=q)
return render(request,'search_results.html',{'book':books,'query':q})
else:
return HttpResponse('please submit a search term')
你沒有該代碼中的第二個或第三個版本。 –