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

dana
  • 5,168
  • 20
  • 75
  • 116

1 Answers1

2

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

Negative votes: {{ object.votedownanswer_set.count }}
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358