I'm trying to get a template to iterate through and print intermediate model data. Can you look at this and point out what is wrong? I've tried to follow the django docs closely:
def category_detail(request, pk): category = models.Category.objects.select_related().get(pk=pk) entries = category.entry.order_by('-temp_sort_order').filter(temp_sort_order__gte=0) for entry in entries: assert isinstance(entry, models.Entry) ce = models.CategoryEntry2.objects.get(entry=entry, category=category) pprint('1: ' + ce.wiki + str(entry.ce)) # works perfectly #foo = entry.ce_set.get(category=category) #'Entry' object has no attribute 'ce_set' #pprint('2: ' + foo.wiki + str(foo.ce)) #'Entry' object has no attribute 'ce_set' for entry in category.ce_set.all: #'Category' object has no attribute 'ce_set' assert isinstance(entry, models.Entry) pprint('1: ' + entry.wiki) return render_to_response('category.html'...) The Category model has a related_name of 'ce'.: class Category(models.Model): title = models.CharField(max_length=1024,null=True,blank=True) entry = models.ManyToManyField(Entry,null=True,blank=True, related_name='ce', through='CategoryEntry2', ) -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/OHaEVYtohSYJ. 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.