2👍
✅
def searchnew(request):
if request.method == 'POST':
name = request.POST.get('name')
loc = request.POST.get('location')
d = {
'name': name,
'loc': loc,
}
return render(request, "searchnew.html", d)
else:
# do the thing you want to do in GET method
name = request.GET.get('name')
na = {
'name': name,
}
return render(request,"searchnew.html",na)
Source:stackexchange.com