Hillary and the DNC deserve a lot of the blame.
Hillary treated the Sanders base like they would pick her eventually anyways (picking Kaine over a candidate like Warren who would have energized the base). Hillary treated Trump supporters like a bunch of idiots (calling them deplorable). She did not campaign in states that her and her campaign didn't even realize were competitive (Iowa, Wisconsin). She hardly ever spoke directly to Sanders supporters. She fundraised with celebrities enhancing her insiders status. She memorized her lines (Trumped-up trickle down). She narrowed her campaign down to the simple fact of her gender (I'm With Her, embracing the idea of playing the gender card, glass ceiling). A flawed candidate, she comes off as arrogant and unsympathetic to millions of men and women. They were over-confident in every regard and deserved to lose.
The DNC and the party in general cleared the floor for this flawed candidate months before a vote was even cast. Potential candidates and party faithful did not throw their hat in the ring because they were told it was Hillary's year. The only people who emerged didn't fit into the DNC's plan, and had problems with another Clinton presidency. To that end, the thumb was put down on Sanders' campaign as much as it could. This ran the gamut from the scant coverage of his remarkable campaign from the MSM to Debby Wasserman Schulz being shown to have been in the bag for Clinton all along. The people who ran the party were working with one candidate, and did not practice impartiality. To that end, over 450 super delegates were already in Clinton's pocket before a single vote was cast, reinforcing the narrative that Sanders could not win with such a deficit. The DNC chose a flawed candidate, and their inability to hear the actual movement that Sanders energized ended up being their undoing.
As Sanders tired old phrase says, the country was tired of establishment politics. Hillary did nothing to shatter this perception (there's not much she could have down, but she could have tried to appear like ordinary folks), and did not realize how serious that idea was.
To that end, I wouldn't be at all surprised if we learned that the DNC really did try to get Trump elected during the primary as an easy victory in the general. They are that out of touch, that thick, that arrogant. Hillary is their leader, but hopefully none of them will be leading anyone anymore.