I have an app for some quiz with questions and choices. So I'm trying to render all this stuff to Django templates. In my views.py it looks like this
def choice(request):
question_list = get_list_or_404(Question)
page = get_object_or_404(Page, name='about')
letters = ["A", "B", "C", "D", "E"]
return render(request,
'qview/choice.html',
{
'question_list': question_list,
'page': page,
'letters': letters,
}
)
I have a list of questions and list with letters. All of that I'm sending as context to my template.
{% if question_list %}
<ul>
{% for question in question_list %}
<li><a href="#">{{question.question}}</a></li>
<ul>
{% for choice in question.choice_set.all %}
<li>{{ choice.text }}</li>
{% endfor %}
</ul>
{% endfor %}
</ul>
{% else %}
<p>No questions available</p>
{% endif %}
So here I'm going through all of questions and all of choices connected to this question. But I can't get how I can also go through letters list? I was thinking about zip it all. But in view I have only questions not choices, so I can't zip to it.
So what else is possible here?