Hello,
I'm clearly missing something obvious with a ManyToManyField. I just want to return a result list for the related table in a View. So here is my Model: class *Supply*(models.Model): name = models.CharField(max_length=200) ... class *Tool*(models.Model): ... supplies = models.ManyToManyField(Supply, related_name=*'supplies'*, blank=True) I want to get a list of Tools for each Supply. Here is my View code: def *supplies*(request, page=*'chemicals'*): renderdict = build_renderdict(request) .... items = Supply.objects.filter(type__exact = type).order_by(*'name'*) if len(items)!=0: itemlist=[] for item in items: #sortedtools = item.tool_set.order_by('shortnamename') print item.name sortedtools = item.tool_set.all() # <------- ERROR HERE itemlist.append({*'id'*:item.id,*'name'*:item.name, * 'minimum'*:item.minimum, *'current'*:item.current, *'reorder'*:(item.current < item.minimum), *'minimum_bmf'*:item.minimum_bmf,*'current_bmf'*:item.current_bmf, *'reorder_bmf'*:(item.current_bmf < item.minimum_bmf), *'status'*: item.status, *'tools'*:sortedtools}) ... Here is the runtime error: 'Supply' object has no attribute 'tool_set' Request Method:GETRequest URL: http://127.0.0.1:8000/qff/whiteboard/chemicals/Django Version:1.2.3Exception Type:AttributeErrorException Value: 'Supply' object has no attribute 'tool_set' Exception Location:/usr/local/django-apps/qff/../qff/whiteboard/views.py in supplies_general, line 924Python Executable:/usr/bin/pythonPython Version: 2.6.6Python Path:['/usr/local/django-apps/qff', '/usr/local/lib/python2.6/dist-packages/icalendar-3.1-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode']Server time:Wed, 13 Mar 2013 10:30:19 -0600 What am I doing wrong? TIA, Frank -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.