@staticmethod
def filtering(queryset, query_dict):
    """
        function to apply the pre search condition to the queryset to narrow
        down the queryset's size

        :param queryset: Django Queryset: queryset of all objects
        :param query_dict: dict: contains selected_related, filter and other
          customized filter functions
        :return: queryset: result after applying the pre search condition dict
        """
    for key, value in query_dict.items():
        assert hasattr(queryset, key
            ), 'Parameter query_dict contains non-existent attribute.'
        if isinstance(value, list):
            queryset = getattr(queryset, key)(*value)
        elif isinstance(value, dict):
            queryset = getattr(queryset, key)(**value)
        else:
            queryset = getattr(queryset, key)(value)
    return queryset
