On Wed, Nov 20, 2013 at 11:18 AM, Pepsodent Cola
<
pepsod...@gmail.com> 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)
articles = Article.objects.all().annotate(num_publications=Count('publication'))