dadapapa
unread,Nov 17, 2009, 11:07:04 AM11/17/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
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.