django prefetch_related() attribute error

How to properly user prefetch_related with ManyToMany relation

my model:

class Subject(models.Model):
    subject_name = models.CharField(max_length=150)
    subject_code = models.CharField(max_length=50)
    year = models.ForeignKey(YearLevel, null=True, on_delete=models.SET_NULL)
    units = models.CharField(max_length=10)

    def __str__(self):
        return self.subject_name + ' ' + '(' + self.subject_code + ')'

class Student(models.Model):
    student = models.ForeignKey(settings.AUTH_USER_MODEL, limit_choices_to= Q(is_student=True), on_delete= models.CASCADE)
    enrolled_subject = models.ManyToManyField(Subject)

my view:

def home(request):
    verses = VerseOfTheDay.objects.all()
    news = Announcement.objects.all()
    student_grade_form = AddStudentGradeForm()
    students = Student.objects.all().prefetch_related('subject_set')
    context = {
        "verse": verses,
        'news': news,
        'form': student_grade_form,
        'students': students,

    }
    return render(request, 'sample.html', context)

my html:

    {% for student in students %}
    <p>
      <a class="btn btn-primary" data-bs-toggle="collapse" href="#collapse{{forloop.counter}}" role="button" aria-expanded="false" aria-controls="collapse{{forloop.counter}}">
        {{student.student}}
      </a>

    </p>
    <div class="collapse" id="collapse{{forloop.counter}}">
      <div class="card card-body">
        {% for subject in student.subject_set.all %}
        {{subject.subject}}
        {% endfor %}
      </div>
    </div>
    {% endfor %}

I am getting an error:

AttributeError at /
Cannot find 'subject_set' on Student object, 'subject_set' is an invalid parameter to prefetch_related()

Answer

Change this line

students = Student.objects.all().prefetch_related('subject_set')

to

students = Student.objects.all().prefetch_related('enrolled_subject')