If fruits is the list [\'apples\', \'oranges\', \'pears\'],
fruits
[\'apples\', \'oranges\', \'pears\']
is there a quick way using django template tags to produce \"apples, oranges, and p
I think the simplest solution might be:
@register.filter def comma_list(p_values: Iterable[str]) -> List[str]: values = list(p_values) if len(values) > 1: values[-1] = u'and %s' % values[-1] if len(values) > 2: return u', '.join(values) return u' '.join(values)