Vincent Uzomah was attacked by a 14-year-old boy, who can't be named for legal reasons, at Dixons Kings Academy, in Bradford, in June.
After the assault the boy bragged on Facebook: "I stick the blade straight in his tummy."'
After a judge ordered the boy to be locked up for up for six years, Mr Uzomah, speaking outside court, said: "As a Christian, I have forgiven this boy who has inflicted this trauma and pain on me and my family.
"It was, however, important for the law to run its course and for a strong message to be sent out, especially to kids of similar tendencies, that violence is never acceptable.
"Our prayer for him is that he will make use of the opportunities and support that will be provided to him, to become a changed person who will make a positive contribution to society."
The boy used an offensive racist term before stabbing Mr Uzomah in the stomach, Bradford Crown Court heard.
Prosecutors told the court the boy was described by others as ''disruptive and a bully'' and had always disliked the teacher.
Jonathan Sharp told the court: "He did not show any especial hostility to other teachers. Mr Uzomah, however, is black.
''The defendant disliked him, claiming he couldn't teach.
''The Crown's case in consequence is that the attack was, at least in part, racially motivated.''
Judge Jonathan Durham Hall QC branded the youth a "dangerous young offender".
He sentenced him to an 11-year extended sentence which includes six years custody and a further five years on licence. He could serve half of the six years.
The judge added: "What you have done is utterly shocking, deliberately, callously stabbing him."
He rejected an application for the youth's identity to be made public saying the 14-year-old's "welfare must come first and the public interest must give way".