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
If you like one-liners:
@register.filter def lineup(ls): return ', '.join(ls[:-1])+' and '+ls[-1] if len(ls)>1 else ls[0]
and then in the template:
{{ fruits|lineup }}