Filter queryset by a comma delimeted cause list

def by_causes(queryset, cause_string=None):
  """ Filter queryset by a comma delimeted cause list """
  if cause_string:
    operator, items = get_operator_and_items(cause_string)
    q_obj = SQ()
    for c in items:
      if len(c) > 0:
        q_obj.add(SQ(causes=c), operator)
    queryset = queryset.filter(q_obj)
  return queryset