Is there a way to check if the student exsist in the database class table, since student is assigned as a forgeinkey in the table. I want to achive this without open another loop. index.html:
<ul>
{% for student in studentList %}
{% if student in classList %}
<li><a href="#">{{ student.name }}</a></li>
{% endif %}
{% endfor %}
views.py
def index(request):
context = {
'studentList': Student.objects.all(),
'classList': ClassRoom.objects.all(),
}
return render(request, 'resurs/index.html', context)