I want to iterate items and return it based on foreign key relationship, but only one item is returning
<p>I have a StudentAttendance model that is a foreign key to Student. I have defined a template to return the days for a particular student and the status. And like wise for Grade, showing all the subject for that student and displaying the grade scored. The code below is only returning one item. For instance, a student attendance was recorded for Monday, Tuesday and Wednesday and only Monday is being returned but I want all to be displayed.</p>

<pre><code>def studentdetails(request, id):
    instance = Student.objects.get(id=id)
    registration = Registration.objects.filter(id=id)
    gradedetails = Grade.objects.filter(id=id)
    studentattendance = StudentAttendance.objects.filter(id=id)

context = {
    "instance": instance,
    "registration": registration,
    "gradedetails": gradedetails,
    "studentattendance": studentattendance,
}
return render(request, "studentdetails.html", context)
</code></pre>

<p>Here's the template:</p>

<pre><code>&lt;div&gt;
{% for day in studentattendance %}
{{ day.day }}: {{ day.status }}
{% endfor %}
&lt;/div&gt;
</code></pre>