def find_users(self, queries, base_queryset=None):
        if base_queryset is None:
            base_queryset = self.all()
        filters = []
        for query in queries:
            match = Q(
                name__istartswith=query) | Q(name__icontains=' %s' % query)
            filters.append(match)

        users = base_queryset.filter(reduce(operator.and_, filters))

        return users
Queries, a list of search queries
dataset/ETHPy150Open tschellenbach/Django-facebook/django_facebook/model_managers.py/FacebookUserManager.find_users