开发者

Django reverse relationship problem

I'm trying to write a reverse relationship 开发者_JS百科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


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

Negative votes: {{ object.votedownanswer_set.count }}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜