0👍
i think that you should have something like a ForeignKey to Question
model to your Vote
model? If it so, you maybe should do something like this:
{% for choice in question.vote_set.all %}
{% empty %}
{% endfor %}
If think that we need more information about your models in order to help you. Please add your models code, at least the Question models.
- [Django]-Django: related_name attribute (DatabaseError)
- [Django]-Django 1.1 – comments – 'render_comment_form' returns TemplateSyntaxError
- [Django]-Django rest framework unique together error message not displayed anymore
0👍
Your for loop
has to be something like that, accessing via reverse_name
question.modelname_set.all
for instance based on your case:
{% for choice in question.choice_set.all %}
<li>{{ choice.choice_text }} --
{{ choice.votes }} vote{{ choice.votes|pluralize }}</li>
{% endfor %}
- [Django]-Python/Django date field in html input tag
- [Django]-How to return most popular items in a table, but where each item is unique?
- [Django]-Django Rest Framework regroup queryset by a category
Source:stackexchange.com