views:

23

answers:

1

I'm trying to write a reverse relationship for taking the number of answers asociated to each question, but all i get is 'Negative voting' repeating as many times as the question is voted negatively, and i don't get why it doesn't display the number of votes instead of that. my code:

{% for object in object.voteupanswer_set.all %}
Positive votes:{{ object.answer.count }}
{% endfor %}
{% for object in object.votedownanswer_set.all %}
Negative votes:{{ votedownanswer.count }}
{% endfor %}

thanks

+2  A: 

Because you should be showing the count, not iterating over each of the entries.

Negative votes: {{ object.votedownanswer_set.count }}
Ignacio Vazquez-Abrams