Вы можете добавить ManyToManyField
в свою модель курса с именем:
class Course(models.Model):
# other fields
students = models.ManyToManyField('Profile',blank=True)`
Поэтому, когда у вас есть экземпляр профиля, этот запрос profile_instance.course_set.all()
отобразит все курсы, которые этот профиль / ученик посетил
По вашему мнению, не отменяйте get_queryset()
{% if user.is_authenticated %}
<p>welcome {{ user.first_name }} --
{% for course in user.profile.course_set.all %}
{{ course.Course_Name }}{% if not forloop.last %},{% endif %}
{% empty %}
<span>No course</span>
{% endfor %}
</p>
{% endif %}
<p><a href="/logout">Logout</a></p>
...