from django.db.models import Q Contact.objects.filter(Q(last_name__icontains=request.POST['query']) | Q(first_name__icontains=request.POST['query']))
User.objects.filter(id__in=[1, 5, 34, 567, 229])