It's clear that there was a systematic problem with the polling that was done during this election. One clue to why the media was so far off is that they focused entirely on speaking to voters.
Political science modeling, on the other hand, seemed to do a better job of predicting a Trump win. This is because they focused on "fundamental-based" factors, which have to do to many underlying trends, including the state of the economy and the tendency of the electorate to vote out the party currently in office. So one lesson that is that we need more robust, comprehensive modeling in the future.