Quentin Tarantino rewrote the ending of 'Django Unchained' at the last minute.

Jamie Foxx revealed the director decided on the "spur of the moment" that the finale he had planned for the forthcoming western movie wasn't going to work, so he went into his trailer on set and changed the ending straight away, much to the surprise of his stunned cast.

Speaking at Comic-Con, Jamie explained: "On the spur of the moment, he rewrote the end of the movie.

"Blows up the house and says, 'My ending doesn't work.' We're like, 'What are you going to do?' 'Just give me a second.'

"He's walking on the rubble like this, 'Okay, I got it.' Goes to his trailer and comes back with the ending of the movie, but dope. When a writer writes a movie, he goes into his cabin and he's there for like nine months, and comes down with like the tablets. This dude just went in his trailer."

Jamie was in disbelief following the filmmaker's revelation, but he now regards him as a "God gifted" individual.

He added: "What? What did you just say? I don't want to cuss, but ****in' crazy. I said, 'There's no way. There's no way. There's no way.' What it is is there's talented people and God gifted people. He's a God gifted people because he went away, he did something, you could tell that it was trouble. When he got it, he came and was like, 'I got this motherf***er now.'"