Given the small margins of Trump victory in Wisconsin, Michigan and Pennslyvania, it is a reasonable conclusion that racists and other deplorables are the reason for Trump's victory.
But, that begs the question of what the Democratic party needs to do in order to win the Presidency.
To start with: by not clinging to a candidate that many democrats, most independents and ALL Republicans don't really like and would ONLY vote for because her opponent was a thousand times worse. Hilary Clinton is the only democratic politician that Republicans hate more than Barrack Obama; they might as well have put Nancy Pelosi as her running mate, just to go for Pissed Off Conservative Bingo.
Here's the thing: the majority of Americans AREN'T actually racist fucks. I'd estimate ten, twenty percent at most, with another thirty to forty percent having actionable but less coherent prejudices and bigotries that they are either barely aware of or think that everyone shares and therefore aren't that special. That still leaves you with 60% of voters for whom Donald Trump being a racist
is not necessarily a deal breaker. For everyone else, that would disqualify him automatically, but there is a class of people in this country who think, at the very least on a subconscious level, that him being a bigoted asshole wouldn't really affect them at all, so he should be judged on other intangible/useless factors.
In which case, Donald Trump is just a fast-talking braggart with a shit ton of money and the willingness to blame all of our problems on easy targets. As long as he's making entitled white people feel like their problems are somebody else's fault (and more than a few of them, that all of their racist/sexist thoughts aren't actually something to be ashamed of after all) then he at least has points for likeability. In order to defeat him, you need to run a candidate who is both likeable and has the balls to propose actual solutions to America's problems without being perceived as cynically triangulating to whatever position the focus groups conclude is most likely to swing a few electoral votes.
I don't think the Democrats could be blamed for misunderstanding the voters. Misunderstanding implies they actually cared what the voters thought in the first place. The entire point of the 2016 election was to get Hilary Clinton in office, and since Donald Trump was her opponent they just assumed he would make a complete ass of himself (which he did) disqualify himself (which he also did) and be such an embarrassment that most normal people couldn't conceive of a Trump Presidency (which they couldn't). The only thing they misunderstood was how thoroughly hated Hilary Clinton really was;
she was quite possibly the only candidate in the United States who stood any chance at all of loosing to Donald Trump. If John McCain or Mitt Romney or, hell, even Mitch McConnell had run against her, any one of them would have beaten her on a landslide.