Thanks Tom it worked! :)
On Wednesday, November 20, 2013 12:18:23 PM UTC+1, Pepsodent Cola wrote:
>
> How can I forloop this count() in my template code?
>
> * I have attached my project files that you might run and see for
> yourselves.
> * I have attached a screenshot of the table I'm working on.
> * User/Pass = joe/joe
>
>
> def index(request):
> publications = Publication.objects.all()
> articles = Article.objects.all()
>
> *sum_publications = Publication.objects.filter(article__pk=1).count()*
>
> context = {'publications':publications, 'articles':articles,
> 'sum_publications':sum_publications}
> return render(request, 'magazine/index.html', context)
>
>
>
>
> How many Publications was each Article in?
>
> {% if articles %}
>
>
> Article id
> Article
> Publication
>
> {% for row in articles %}
>
> {{ row.id }}
> {{ row.headline }}
> *total*
>
> {% endfor %}
>
> {% else %}
> No Articles are available.
> {% endif %}
>
>
> **
> {% if 666sum_publications %}
>
> {% for row in sum_publications %}
> {{ row }}
> {% endfor %}
>
> {% else %}
> No sums are available.
> {% endif %}
>
>
>
>
>
>
--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/6a99dfe0-15af-48e2-ae32-498dcf782d6c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.