I'd like to list a series of items separated by commas.
But if an item after the first doesnt exist, I don't want the comma or item to appear.
So I've implemented this:
<em>{{object.item1|default_if_none:""}}</em>
{% if object.item2 %}
<em>, {{object.item2|default_if_none:""}},</em>
{% endif %}
<em>{{object.item3|default_if_none:""}}</em>
If object.item2 exists, it'll put a whitespace after item1--before the comma.
When it displays, it'll look something like:
"I_am_item_one , I_am_item_two, Item_three"
What's the best way to fix this?
edit: is it possible to for-loop through an object's properties?
{% for property in object.property %}
or similar..