I have a list of tags, and for each element in this list I want to count 
number of questions, which are related to tags as many-to-many.

> def localhost(request):
> tag_list = Tag.objects.all()
>
> #size = Question.objects.filter(tags__pk=tag.pk).count()
>
> return render_to_response('localhost.html',
>                           {#'size': size, 
>                             'tag_list': tag_list,},
>                           context_instance=RequestContext(request))
>
> The problem is I don't know how to get "tag" to write "tag.pk" in query. 
But "tag.pk" is defined in template inside the loop for. How can I take it 
from there? 

> {%for tag in tag_list %} 
>
> {{tag.pk}} {{ size }}  <br>
>
> {% endfor %}   
>
> I tried to make another loop in views but of course it failed, because 
they were separate from each other.

-- 
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.


Reply via email to