In a view I can do:
l = ['one', 'two', 'three']
', '.join(l)
>>> 'one, two, three'
Is there a way to do the same in the template, or do I need to create a custom template filter?
There is a builtin filter for this. From the docs
Filter arguments that contain spaces must be quoted; for example, to join a list with commas and spaces you’d use
{{ list|join:", " }}.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With