Re: Nested for loops in template

2008-07-18 Thread brianmac44
That worked. I just updated my entries model to include comments = generic.GenericRelation(FreeThreadedComment) Thanks. -Brian On Jul 18, 12:30 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote: > Brian, I think the solution is to add a GenericRelation to your entries > model; > seehttp://www.djang

Re: Nested for loops in template

2008-07-18 Thread Scott Moonen
Brian, without knowing exactly how your models are configured, you can do something like this: {{ p.comment_set.count }} If you use it in more than one place (e.g., as {% if p.comment_set.count %} ... {{ p.comment_set.count }} ...), you will want to optimize things so that the SQL "COUNT()" query

Re: Nested for loops in template

2008-07-18 Thread Scott Moonen
Brian, I think the solution is to add a GenericRelation to your entries model; see http://www.djangoproject.com/documentation/contenttypes/#reverse-generic-relationsfor an explanation. I think that after doing this you'll be able to access p.comments.count (assuming that the generic relation is na

Re: Nested for loops in template

2008-07-18 Thread brianmac44
Hi Scott, Thanks for your help, but I'm still having trouble. I using django-threadedcomments http://code.google.com/p/django-threadedcomments/ so its a little confusing. Here are my models http://dpaste.com/65848/ -Brian On Jul 18, 12:01 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote: > Brian,

Nested for loops in template

2008-07-18 Thread brianmac44
I have two tables, one is entries and the other is comments. In the template I would like display how many comments for each entry and some other entry data. So far I have... view: entries_list = entries.objects.filter( ...) template: {% for p in object_list %} {{ p.na