# my coding looks like this in views.py but somehow it only search by name 
no matter which gender i select .what am i doing wrong?

def search(request):
if request.method=='POST':
srch = request.POST['srh'] 
srchs =  request.POST['gender']

if srch and srchs:
match = Snippet.objects.filter(Q(name__istartswith=srch)) 
matchs = Snippet.objects.filter(Q(gender__iexact=srchs))

if match and matchs:
return render (request,'search.html',{'sr':match})
#return render (request,'search.html',{'sr':match})
else:
messages.error(request,'no result found')
# return HttpResponse("<h1>No name found please Add names  </h1>")

else:
# return HttpResponseRedirect('/search/')
return render(request,'search.html')

return render(request,'search.html')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/35681b7b-b12e-45bc-8206-396bd3874266%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to