Use `self.user.roles.filter(name="Student", course_id=course_id)` instead