I believe it's also important to give trump credit for his competence in electoral basics. This was evident enough when early in the campaign he was asked about support from David Duke, and you could see the gears turning in his head judging how to play to the voters he'll need. Any establishment candidate would've followed conventional reasoning, renounced immediately and gave up a lot of votes, and in hindsight that would've clearly been the wrong move.
Since then he's similarly judged what crowds respond to very well, and adjusted his rhetorical accordingly whether it's banning muslims following a muslim shooting, claim the system is rigged when numbers turned against him, or whatever else came his way. In some sense you can't just blame stupid people for being stupid and easy to play; that's simply how they are. Playing them right is fundamental to the game of politics; and trump is simply superior at this compared to clinton.