from django.db.models import Q Contact.objects.filter(Q(last_name__icontains=request.POST['query']) | Q(first_name__icontains=request.POST['query']))