I posted a question earlier today about circular imports (http://
groups.google.com/group/django-users/t/6119e979131c8c25).  I now have
a follow question to that.  I've got the following view logic.

def portal(request):
    scientist_id = 1
    s = get_object_or_404(Scientist, pk=scientist_id)
    return render_to_response('scientists/portal.html',
{'scientist':s})

Now, Scientists are related (many-to-many) to Conferences through
ConferenceAttendee.  Both of these models are created in a different
app.  I won't paste them in unless someone needs to see them in order
to answer my question.

I only want to loop through conferences that this scientist is
presenting.  (ConferenceAttendee.presenter=True).  I have tried
following the docs (http://docs.djangoproject.com/en/dev/topics/db/
queries/#field-lookups-intro), but it seems that you can only call the
filter method in python files like views.py or models.py.  I've tried
replacing the loop code below with "for ...conference._set.filter(...)
but python gives me errors when I do that.  Here is my template logic.

<h2>Your Presentations</h2>

<ul>
    {% for conference in scientist.conference_set.all %}
        <li><a href="/conferences/{{ conference.id }}">
{{ conference.title }}</a><a href=""><img src="/site_media/images/
portal_start_button.jpeg" /></a></li>
    {% endfor %}

</ul>

I've been stuck on this one for days now so any help would be greatly
appreciated.  Please do point me to any articles that I may have
missed that already answer this post.

Thank you,

Guy
--~--~---------~--~----~------------~-------~--~----~
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