Django ManyToManyField Not Displaying in Template

193 views
Skip to first unread message

Rodney Lewis

unread,
Dec 17, 2014, 9:52:19 AM12/17/14
to django...@googlegroups.com
Hey All:

I need my template to iterate through each PartModel and then iterate through the PartModels associated (through a self-referential ManyToManyField) with the PartModel in question. I am doing everything I'm supposed to be doing according to my reading of the "entry_set syntax" section of the "Making Queries" section of the docs to no avail.

http://stackoverflow.com/questions/27527717/django-manytomanyfield-not-displaying-in-template

Thank you in advance for any assistance!

Collin Anderson

unread,
Dec 19, 2014, 5:46:24 PM12/19/14
to django...@googlegroups.com
Hi,

Did you figure it out?

This should work:

{% for p1 in partmodels %}
   
{% for p2 in p1.partmodel_set %}
       
{{ p2 }}
   
{% endfor %}
{% endfor %}

Collin
Reply all
Reply to author
Forward
0 new messages