The for loop in Django 1.2 includes several automatically generated variables. Among them:
forloop.first
forloop.last
So you can put the separator using the if statement:
<p>
{% for u in users %}
{{u.name}}
{% if not forloop.last %}
,
{% endif %}
{% endfor %}
</p>
source
share