Filter queryset by publish status

def by_published(queryset, published_string='true'):
  """ Filter queryset by publish status """
  if published_string == 'true':
    queryset = queryset.filter(published=1)
  elif published_string == 'false':
    queryset = queryset.filter(published=0)
  # Any other value will return both published and unpublished
  return queryset