[Django]-Django – 'for' statements should have at least four words: for choice question_set.all

3👍

You’ve just forgotten the statement in

{% for choice in question_set.all %}

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.

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 %}

Leave a comment