i have piece of code @ views, intend filtering various fields in database model called orderitem.
here code:
def search_form(request): if 'q' in request.get , request.get['q']: x = request.get['q'] q = x.title() print q x = request.get['certification_type'] print x items = orderitem.objects.filter(q(order_type__iexact=x , order_type__iexact=q) | q(certification_type__iexact=x , certification_type__iexact=q) | q(item__iexact=x , item__iexact=q) | q(certification_no__iexact=x , certification_no__iexact=q) | q(client__user__email__iexact=x , client__user__email__iexact=q) | q(client__phone_number__iexact=x , client__phone_number__iexact=q) | q(created_on__icontains=x , created_on__icontains=q)) x in items: q in items: print items return render(request, 'i/search_results.html', {'items':items, 'query':q}) else: return render(request, 'i/search_form.html', {'error':true})
but if try find items under certification_type, empty list [] @ console. don't know missing
Comments
Post a Comment