def obligation_list(request, org_name):
org = Organization.objects.get(slug=org_name)
oblig_list = org.obligation_set.all()
return render_to_response('obligationList.html',
{'oblig_list': oblig_list, 'organization':
org},
RequestContext(request))
Here's the (relevant part of the) model:
class Obligation(models.Model):
organization = models.ForeignKey(Organization, editable=False)
And the (relevant part of the) error I get in the browser:
Template error
In
template /home/tobryan1/workspace/dmi/src/dmi/orgs/templates/obligationList.html, error at line 18
Caught an exception while rendering: 'ManyRelatedManager' object is not
iterable
18 {% for obligation in oblig_list %}
Any ideas what's going on?
Thanks,
Todd
The Manager isn't iterable, but the query sets it produces are.
You're looking for:
{% for obligation in oblig_list.all %}
Yours,
Russ Magee %-)
def obligation_list(request, org_name):
org = Organization.objects.get(slug=org_name)
--> oblig_list = org.obligation_set.all()
return render_to_response('obligationList.html',
{'oblig_list': oblig_list, 'organization':
org},
RequestContext(request))
Todd
--
Mohamed Hussein
http://www.unixgarage.com
Todd
Well, yes, if only because the error message made you look in the
wrong place. If you can provide a specific (cut down) example where
the template parser produces the wrong line number, it may be possible
to improve the error message.
Yours,
Russ Magee %-)