i am trying to print a list of all the Conferences and for each conference, print its 3 Speakers.
in my template i have:
{% if conferences %}
<ul>
{% for conference in conferences %}
<li>{{ conference.date }}</li>
{% for speakers in conference.speakers %}
<li>{{ conference.speakers }}</li>
{% endfor %}
{% endfor %}
</ul>
{% else %}
<p>No Conferences</p>
{% endif %}
in my views.py file i have:
from django.shortcuts import render_to_response
from youthconf.conference.models import Conference
def manageconf(request):
conferences = Conference.objects.all().order_by('-date')[:5]
return render_to_response('conference/manageconf.html', {'conferences': conferences})
there is a model named conference. which has a class named Conferences with a ManyToManyField named speakers
i get the error: Caught an exception while rendering: 'ManyRelatedManager' object is not iterable with this line: {% for speakers in conference.speakers %}