I'm using annotate with my Django queryset to count a number of records. I am using it with filter and understand the order makes a difference.
My query is: numcontestants = Contestant.objects.filter(assigned_team__id=urlid).annotate(num_contestants=Count('id'))
When I pass numcontestants to my template and display it with {{ numcontestants }} I see a queryset containing each of the records I want to view. When I try with:
{{ numcontestants.num_contestants }} I get nothing.
I don't want to have to iterate over numcontestants to get a count, my understanding was that num_contestants should be a single integer number. Even so, iterating over doesn't give the result I am after, for example using:
{% for x in numcontestants %} {{x.num_contestants}} {% endfor %}
outputs 1 1 1 when I am trying to get something that will output 3.
What is the right way to generate and access a sum count?