President Trump shakes hands with former president Barack Obama at Trump’s inauguration on Jan. 20, 2017. (Jonathan Newton/The Washington Post)

For more than two centuries, until the election of 2008, American presidents all looked alike. They were white and male and every one of them came to office with experience in the government, military or both. Barack Obama, the first African American president, broke one mold. Donald Trump, who had neither military nor government experience, broke the other.

In their own ways, Obama and Trump were two of the most unlikely people ever elected to the presidency, raising the question of whether voters in America are using a new lens through which to judge the qualities and qualifications of presidential aspirants. Trump’s presidency continues that experiment, as does the competition among the candidates seeking the Democratic nomination to oppose him in 2020.

Bob Tyson is a retired database consultant who lives in Chapel Hill, N.C. He is a Trump supporter and says the president has helped change his thinking about the qualities needed for someone to hold the nation’s highest office.

“Having that celebrity personality and projecting an image in the media is more important than traditional qualifications,” he said. “It’s made me think differently about what it takes to be elected president. The traditional path of being a state governor or U.S. senator doesn’t seem to count as much. It’s being able to manage your image in the media and galvanizing your base.”

Will and Wendy Keen were in the audience at the Big Grove Brewery and Taproom in Iowa City a few weeks ago, awaiting the arrival of former vice president Joe Biden. They have been making what Will called “a diligent effort to connect with each of the candidates” campaigning in their state.

One person who has caught their eye is South Bend, Ind., Mayor Pete Buttigieg, a candidate who, at age 37 and the leader of a relatively small city, might not have been seen in years past as having the experience needed for the presidency.

“The recent reality,” Will Keen said, “has taught us that our vision of what a president looks like, talks like, acts like, has been dramatically changed.” The elections of Obama and Trump, he said, have caused people “to be open to things you might not have expected.”

Many factors have contributed to this change, among them the diversification of the nation’s population; the effect of a nominating system that puts personal ambition and direct communication skills above credentialing by party leaders; the evolution of the role of traditional media and more recently social media; and especially the deepening disillusionment on the part of many Americans with traditional politics and politicians in Washington.

From George Washington through George W. Bush, no characteristic was more enduring in American presidents than the monopoly of white men. No women or candidates of color made much of a dent on the presidential selection process. Candidates of color ran for their parties’ nomination and lost. Women ran for the nomination and lost. Women were nominated to be vice president with no success. In 2016, Hillary Clinton claimed the Democratic nomination, the first woman to do so in a major party, and she, too, lost.

Obama, the son of a white mother and black African father, possessed few of the traditional qualifications of previous presidents, among them experience on the national stage. He had served in the U.S. Senate only since 2005 when he was elected president. His election not only broke the racial barrier but also helped open the process to reflect a changing America.

“If you look at what people historically have considered to be acceptable characteristics of their presidents, in terms of ­social characteristics — white, male, married, Christians, neither too young nor too old — those categories have all been shattered,” said Michael Nelson, a political scientist who teaches at Rhodes College. “Not that we’ve elected a woman, but a woman has made it to the finals. The same might be true of sexual orientation.”

Erin Hamilton of Fort Riley, Kan., said she warmed to Trump after her first choice in 2016, Ted Cruz, failed to win the nomination. “I liked that he was not typical, that he didn’t have a whole bunch of political background, that he just did this because he wanted to. . . . I would like to see more people running for the president who maybe don’t have a strong political background.”

Rob Burns, who works in the university bookstore at the University of Iowa, said he is less concerned about traditional credentials as he assesses presidential candidates this year.

“Character is the biggest thing,” he said. “I think if you look back at our best presidents, it’s always their character. It’s not their politics.”

Marc Hetherington, a political scientist at the University of North Carolina, said cultural changes in the makeup of the country have reshaped the political makeup of the parties.

“Presidential prototypes are going to be different as a result,” he wrote in an email.

That’s one reason, perhaps, why there are now 23 candidates for the Democratic nomination, including six women and six candidates of color — diversity unheard of in past elections. They range from Biden, the candidate with the longest résumé, to sitting senators to governors or ex-governors to a big group of current or former House members to a mayor of a small city, a big city or the nation’s largest city, to an entrepreneur to a spiritual activist and author.

Out of this field could emerge the oldest person ever elected as president, or the youngest. It could produce the first female president, the first woman of color as president, the first Latino president, the first Asian American president, the first openly gay president, the first mayor to ascend directly to the White House.

Hetherington believes that a changing Democratic Party makes nontraditional candidates more attractive to some party activists. As consumers, he said, many of those Democrats are more likely to be attracted to niche products — fair-trade coffee as opposed to the opposite, for example — and that helps to explain why the base of the party acts as it does.

“What could be more niche than a young congressman who used to play in a punk band in Texas [Beto O’Rourke]? Well, maybe a gay mayor from a small city in the Midwest [Buttigieg],” he wrote.

Candidates today worry less about establishment credentialing because there are new ways to build a political brand.

“We’ve become a more democratic, small-D, society,” said pollster Peter Hart. “There’s no establishment. There aren’t bosses and kingmakers. We’re in a freelance society at this stage of the game. With everything that’s happening on social media . . . the barriers to entry are so much lower.”

Cues from party leaders count for less, as candidates build their own followings. Sid Milkis, a political scientist at the University of Virginia, argued that, for all their differences, Trump and Obama share something more than nontraditional résumés. “They see or saw themselves as heads of a movement. They didn’t just envision themselves as presidential candidates,” he said. “And secondly, both kept their distance — and you could say weakened — the official party organization.”

Not only have barriers to entry been lowered, but the qualifications that were once considered assets now can carry liabilities. At a time of gridlock and constant partisan warfare, legislative experience in Washington has been devalued. The baggage of thousands of votes can easily become a burden to a longtime incumbent. Biden is proof of that, as he has had to answer for or explain decisions and votes he took decades ago that have been reinterpreted through the lens of today’s politics.

Candidates today also know that the opportunity to become president must be seized, even if more seasoning would be helpful.

“Obama was an example of that,” said Joel Goldstein, a professor at Saint Louis University School of Law. “Even though you’ve got [Hillary] Clinton running [in 2008], people were saying don’t wait around.”

That was the message David Axelrod, Obama’s chief strategist, gave to the young senator as he was making his final decision to run for president.

“History is replete with potential candidates for president who waited too long rather than examples of people who ran too soon,” he wrote in a memo in late 2006. “You will never be hotter than you are right now.”

The cycles of history have produced varying paths to the presidency. In the earliest days, as America was still in its formative stages, one common characteristic was diplomatic experience, as ambassadors abroad or service as secretaries of state. John Adams, Thomas Jefferson, James Madison, James Monroe and John Quincy Adams all shared this in their résumés.

Adams and Jefferson also served as vice president, the first two of 14 men who occupied that office. Some of the 14 ascended to the presidency upon the death or resignation of a president; others were elected outright. In the 1960s and ’70s, three presidents in a row — Lyndon B. Johnson, Richard M. Nixon and Gerald R. Ford — had served as vice president.

Through much of the 20th century, governmental experience marked the résumés of presidents. Herbert Hoover had earned a reputation as a skilled executive by organizing humanitarian relief efforts in Europe after World War I and later distinguished himself as a commerce secretary with outsize influence. Franklin D. Roosevelt had served as assistant secretary of the Navy during World War I, vice-presidential nominee in 1920 and a term as governor of New York on his way to the presidency.

In the decades immediately after World War II, Americans elected a succession of presidents with notable Washington experience. Harry S. Truman was a 10-year veteran of the Senate before becoming Roosevelt’s vice president. Dwight D. Eisenhower’s military career included Washington experience and the invaluable role as commander of the allied forces that liberated the European continent from the Nazis. Johnson, Nixon and John F. Kennedy served in both the House and Senate. Ford spent more than two decades in the House, including more than eight years as Republican leader.

“Then we turned a page,” said Roger Porter, a professor of government at Harvard’s Kennedy School and a former White House adviser to Presidents Ford, Ronald Reagan and George H.W. Bush. From 1976 until the election of 2008, most of the successful candidates (George H.W. Bush being the exception) shared two qualities: state government experience and the claim of being a Washington outsider.

Jimmy Carter was the first of the new breed, a one-term governor of Georgia who ran for the Democratic nomination against a large field of candidates, many with deep Washington experience. But after Vietnam and Watergate, Carter caught the mood of an electorate disillusioned with the federal government and its leaders. He was untarnished by Washington but still offered executive experience at the state level.

Carter’s election “opened the floodgates” to this different model of presidents, Nelson said. After Carter came Reagan, who had been the two-term governor of California. In 1992, the country elected Bill Clinton, the young governor of Arkansas, turning out Bush, who had been Reagan’s vice president, after a single term. Clinton was succeeded by Bush’s son, George W. Bush, who in addition to his family name had twice been elected governor of Texas.

“We said we want people to have executive experience, but we’re happy to have it in state government,” Porter said. “Now we have had two presidents who had none of that.”

People often point to Abraham Lincoln as an example of someone who came to the presidency with virtually no governmental experience, just a single term in the House as a representative from Illinois. In contemporary terms, Lincoln had a background that is not dissimilar to that of Beto O’Rourke, who is running for the Democratic nomination today: service in the House and a losing campaign for Senate that nonetheless helped vault him to national prominence.

For Lincoln, it was the historic debates with Stephen A. Douglas that propelled him forward. Historian Doris Kearns Goodwin noted that those debates were later published and distributed nationally. That brought Lincoln speaking invitations beyond the borders of Illinois, including his powerful anti-slavery speech at Cooper Union in New York in early 1860 that helped win him the nomination and presidency.

“It spread his name beyond Illinois,” Goodwin said. “He became a national figure because of those debates.”

Trump isn’t the first president with celebrity appeal. Theodore Roosevelt became famous through the Spanish-American War. Eisenhower had near-universal stature as a war hero. In 1960, Kennedy lacked the reputation of some of the giants in the Senate, including Johnson, but had the qualities of glamour and family riches that helped to elevate him.

The power of television and social media have made celebrity an important, if not essential, quality for someone seeking the presidency in this era. Today a politician can create some celebrity appeal almost overnight. Buttigieg initially caught the attention of Democratic activists through a CNN town hall. O’Rourke drew a national audience last year through a viral video in which he defended pro football player Colin Kaepernick for taking a knee during the national anthem.

Rep. Alexandria Ocasio-Cortez (D-N.Y.) is the ultimate example. She wasn’t known a year ago. “Now she’s on the cover of magazines,” Goodwin said. If she were 35 years old rather than 29, it’s likely she would be talked about as a possible candidate for president.

Trump’s celebrity proved to be one of the most important assets in 2016. Though he was a well-known businessman, he could not claim the executive skills of the head of a company with tens of thousands of employees. Instead, his background as a reality TV star distinguished him from other candidates for the GOP nomination — and allowed him to use media to his advantage.

“Trump is in some ways the culmination of these trends that have been underway since the Vietnam and Watergate era,” Nelson said. “What Trump added was [being able to say], ‘I’ve never held office in Washington. I’ve never held office at all. That’s all the more reason to send me to drain the swamp.’ ”

Trump supporters point to this quality as one of the reasons they were attracted to him as a candidate. When asked what he liked about Trump, Jeff Bartulla, who lives in Montgomery, Tex., and works in the oil field services industry, said: “That he wasn’t part of government. I was sick of watching [members of Congress] twiddle their thumbs and make excuses.”

The victories by Obama and Trump have rewritten the history of presidential politics. One contribution by Obama — the breakup of the white male hold on the presidency — appears likely to be a permanent change, though obviously not in every single election in the future. At a minimum, no one expects the Democratic ticket in 2020 to be composed of two white men.

Democratic voters appear torn about what they want in a nominee, attracted to newcomers but not ready to make a final judgment. Judy Stavitz of Toms River, N.J., who badly wants Trump defeated, said that the mold of what kind of person can be president “has been broken by the buffoon in the White House right now.” So far she has found Buttigieg appealing — but also sees merit in Biden.

That is one reason Harvard’s Porter questioned whether the most recent elections signal a genuine shift in the kind of candidate future voters will favor or whether they were the result of special circumstances.

Will the experience of the Trump presidency push voters back to a more traditional candidate? Perhaps, but voters seem far more willing to weigh many options these days. Bob Tyson, the North Carolina Republican, put it this way: “I think voters are willing to consider anybody, if they make the right impression on them.”

Correction: An earlier version of this report misidentified the university where Joel Goldstein teaches. Goldstein is a professor at Saint Louis University School of Law.