On Thu, May 28, 2009 at 11:33 PM, Brian May
<br...@microcomaustralia.com.au>wrote:

>
> Hello,
>
> Simple question, can I make the following list comma seperated without
> inventing my own custom tag type?
>
> {% for pp in object.photoperson_set.all %}<a href="{{
> pp.person.get_absolute_url }}">{{pp.person}}</a> {% endfor %}
>
> I don't want a comma before the first item or after the last item.
>
> I have a number of these lists, for different data types, and rather not
> have
> to create a custom tag for every one. If I can help it.
>
> Thanks.
> --
> Brian May <br...@microcomaustralia.com.au>
>
> >
>
Loops put some vary helpful variables in the context, so you can do
something like:

{% for pp in object.photoperson_set.all %}<a href="{{
pp.person.get_absolute_url }}">{{pp.person}}</a>{% if not forloop.last %},
{% endif %} {% endfor %}

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to