yes! that works exactly the way i wanted
shouldnt that be part of Django? feels like a very fundamental piece
of logic.
Also yeah you're right about the URL.

On Apr 20, 6:14 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Sun, 2009-04-19 at 16:40 -0700, Johan wrote:
> > Hello
> > I have a problem I cant get my head around.
> > I want to list through a bunch of people and see which one im friends
> > with and which ones i can add as a friend. sort of twitter style.
> > If it throw in an else it will hit on every step of the 2nd
> > (supporters) loop, I obviously want either supporter OR an add me
> > link.
>
> > {% for d in dreamers %}
> >     <p>
> >     <a href="/user/{{ dreamer.user }}">{{ d.user }}</a>
> >       {% for s in supporters %}
> >                    {% ifequal d.id s.id %}
> >                         supporter
> >                    {% endifequal %}
> >            {% endfor %}
> >     </p>
> > {% endfor %
>
> > result:
>
> > johan
>
> > sven supporter
>
> > glen supporter
>
> > ben
>
> > ken
>
> > {% for d in dreamers %}
> >     <p>
> >     <a href="/user/{{ dreamer.user }}">{{ d.user }}</a>
> >       {% for s in supporters %}
> >                    {% ifequal d.id s.id %}
> >                 supporter
> >                 {% else % }
> >                    add me!
> >                    {% endifequal %}
>
> >            {% endfor %}
> >     </p>
> > {% endfor %
>
> > result:
>
> > sven  supporter add me!
>
> > glen add me! supporter
>
> > ben add me! add me!
>
> > ken add me! add me!
>
> Looks like you hit the same thing I did. What you want to do is test to
> see if d is in supporters, so something like this:
>
> {% for d in dreamers %}
>     <p>
>     <a href="/user/{{ dreamer.user }}">{{ d.user }}</a>
>       {% IfInList d in supporters %}
>         supporter
>       {% else % }
>         add me!
>       {% endif %}
>     </p>
> {% endfor %}
>
> Unfortunately, this doesn't exist yet in django, I added an
> implementation of IfInList if you want a custom tag [1], or you can wait
> for us to stop arguing about the right way to do it [2] and have it in
> the regular if tag.
>
> (Also, your href link should really be using {% url %} and should it
> really be 'dreamer.user' and then 'd.user'?)
>
> Cheers
>
> Tom
>
> [1]http://code.djangoproject.com/ticket/10821
> [2]http://code.djangoproject.com/ticket/8087
--~--~---------~--~----~------------~-------~--~----~
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