I have this url after you hit the search button:
127.0.0.1:8000/results/?name=blab&city=bla&km=12
my view:
def search(request):
name = request.GET.get('name')
city = request.GET.get('city')
km = request.GET.get('km')
if name!="" and name != None:
locations = Location.objects.filter(name__istartswith=name)
return render_to_response("result-page.html",{'locations':locations},context_instance=RequestContext(request))
if city!="" and city != None:
locations = Location.objects.filter(city__istartswith=city)
return render_to_response("result-page.html",{'locations':locations},context_instance=RequestContext(request))
but now, if i look for both name and city, it is giving ony the results search after name. e.g. the first paramater. second one is not being taken.
what is the best logic for this? i also want to able to sort the search result. can you please give me some hints how to this kind of things in clean logic.
thanks