Django反向关系问题
我正在尝试编写一个反向关系来获取与每个问题相关的答案数量,但我得到的只是“否定投票”,该问题重复多次,而我不明白为什么会这样。 t 显示票数而不是票数。 我的代码:
{% 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 %}
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为您应该显示计数,而不是迭代每个条目。
Because you should be showing the count, not iterating over each of the entries.