I am doing a quiz project, in which I am showing the list of quizzes made in the template, but the name of the quiz is being duplicated, I know that it is doubling the name because I have two for, but there is a way that only show the name of the quiz once.
view:
@login_required(login_url='testinglogin')
@user_passes_test(is_testing)
def testing_marks_view(request):
dict = {
'results': QMODEL.Result.objects.all(),
'courses': QMODEL.Course.objects.all(),
'testing': TMODEL.Testing.objects.all(),
}
return render(request, 'testing/testing_marks.html', context=dict)
Template:
{% for c in courses %}
{% for r in results %}
{% if c.id == r.exam_id %}
<tr>
<td>{{ c.course_name }}</td>
<td style="..."><a class="btn btn-success btn-block radio" href="{% url 'check-marks' c.id %}"><i class="fas fa-eye"></i></a></td>
</tr>
{% endif %}
{% endfor %}
{% endfor %}
This is the list that appears to me. I have a quiz with that name, but since I answered twice, the same quiz appears twice.