Dear list,

I have two models that are in the following relationship:

class Member(django.contrib.auth.models.User) :
        # some app specific stuff here
        pass

class Event(django.db.models.Model) :
        attendees = models.ManyToManyRelation(Member)
        # some other fields


In my template, I want to iterate over an Event QuerySet and render
the
output differently depending on whether the currently logged in member
attends an event or not:

{% for event in event_list %}
{% if request.user.member in event.attendees %}
        render something here
{% else %}
        render something else
{% endif %}
{% endfor %}

Obviously, the if tag that tests for attendance is ill-formatted, but
I cannot
figure out the correct solution. I went through the documentation and
googled
for a solution but cannot find it. Do I really need to  write a custom
{% ifcontains event.attendees request.user.member %} tag that would
check if
a given queryset contains an object, or am I missing something the
obvious?

Thanks.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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=.


Reply via email to