def find_users(self, *args):
        """
        Returns the users to search given names as args.
        Return all users if there are no args provided.
        """
        if args:
            names = reduce(lambda query, arg: query |
                (Q(first_name__icontains=arg) | Q(last_name__icontains=arg)),
                args, Q())  # noqa
            users = User.objects.filter(names)
        # If no args given, check every user
        else:
            users = User.objects.all()
        # Display errors if no user was found
        if not users.count() and args:
            if len(args) == 1:
                raise CommandError('No user was found with the name %s' % args[0])
            else:
                arg_list = ', '.join(args)
                raise CommandError('No users found with the names: %s' % arg_list)
        return users
def find_users ( self , * args ) : if args : names = reduce ( lambda query , arg : query | ( Q ( first_name__icontains = arg ) | Q ( last_name__icontains = arg ) ) , args , Q ( ) ) users = User . objects . filter ( names ) else : users = User . objects . all ( ) if not users . count ( ) and args : if len ( args ) == 1 : raise CommandError ( 'No user was found with the name %s' % args [ 0 ] ) else : arg_list = ', ' . join ( args ) raise CommandError ( 'No users found with the names: %s' % arg_list ) return users
Returns the users to search given names as args.
        Return all users if there are no args provided.