When President Obama visited the Islamic Society of Baltimore on Wednesday in his first visit to a mosque during his presidency, he issued a sharp rebuke to the entertainment industry.

“Part of what we have to do is to lift up the contributions of the Muslim-American community not when there’s a problem, but all the time,” Obama said. “Our television shows should have some Muslim characters that are unrelated to national security. It’s not that hard to do. There was a time when there were no black people on television and you can tell good stories while still representing the realities of our communities.”

I’m with Obama in believing that it’s long past time that Hollywood moved beyond its tired Muslim terrorist plots and into a broader representation of people who practice Islam both at home and abroad. But I think he’s making a tactical mistake in comparing the representation of Muslims to that of African Americans, and not just because Muslims are people of many races and ethnicities. Islamophobia certainly plays a role in the persistence of these storylines. But if Hollywood has trouble telling stories about Muslims in other contexts, that’s in part because the entertainment industry isn’t very good at talking about the daily practice of religion, no matter what a character’s faith is.

Hollywood tends to use religion in two ways: the first is to actually drive the plot of a show or movie.

“Spotlight,” Tom McCarthy’s Oscar-nominated movie about the Boston Globe’s reporting on the Catholic church’s coverup of widespread sexual abuse by a startling number of priests, is terrific not least because it examines the power of the church in the region in a way that goes beyond ethnic color. The film paints a portrait of the lawyers, school administrators, police officers and ordinary civilians who deferred to Cardinal Bernard Law (Len Cariou) or carried out his wishes, and tallies the cost that dissenters paid for speaking out against the church, even to expose serious crimes.

“The Americans,” FX’s drama about deep-cover KGB spies raising a family in the Washington suburbs, has carved out space to examine Paige Jennings’s (Holly Taylor) conversion to Christianity because it’s a major driver of the action on the series. Paige’s attraction to religion as a framework that teaches her how to be good threatens her parents, Elizabeth (Keri Russell) and Philip (Matthew Rhys), who hope that Paige can eventually be a second-generation spy for the atheist regime to which they’ve pledged their lives. And after Elizabeth and Philip tell Paige who she really is, her faith and conscience ultimately lead her to confess to her pastor (Kelly AuCoin) in the final episode of the third season.

Similarly, in the CW’s darling telenovela “Jane the Virgin,” Jane’s (Gina Rodriguez) Catholic faith is the key to explaining her response to a patently absurd situation. In the pilot for the show, Jane, who does not plan to have sex until she gets married, is accidentally inseminated and becomes pregnant. If she wasn’t devout, Jane might simply have terminated the pregnancy and extricated herself from the whole mess, and there would be no show as a result.

That mass culture often depicts Muslisms as terrorists absolutely grows out of the prejudices that bloomed like ugly flowers after Sept. 11 and have continued to grow like weeds in the years since. But these storylines are also a result of the entertainment industry’s bias toward using religion to drive the action in storytelling, rather than to flesh out character details or to drive smaller-bore plots.

Now, it’s true that pop culture often uses religion to supply the aforementioned ethnic color. But there, religion often serves as a sort of shortcut rather than an opportunity to really explore the experience and practice of faith.

There is no quicker shorthand for the contradictions of an Irish or Italian gangster than to establish his Catholic faith (followed quickly by the depth of his affection for his mother). Only 2.2 percent of Americans are Jewish, but Yiddishisms, as well as tropes like neuroses, over-involved mothers and smoked fish, are so deeply established that it’s easy to sketch in the same sort of detail with just a few references. And black church choirs are both a signaling mechanism and a lovely visual and sonic device to drop into a movie or episode.

These signalling mechanisms work in part because they’re already familiar to viewers. And while they may be stereotypes — it will take years for Jewish characters in pop culture to escape the shadow of Woody Allen — these tropes at least guarantee some generally genial representation.

Such mass-culture shorthand just doesn’t exist for Muslims and for Islam. Polls consistently suggest that Americans don’t know very much about Islam, and the number of survey respondents who say that Islam is incompatible with American values has grown in recent years. Action movies might throw in an early-morning call to prayer, but in this environment of mistrust and suspicion, that sound might as easily signal trouble as piousness and community feeling.

If Hollywood is going to find new ways to depict both Muslims and the practice of Islam, the industry will have to swim against public sentiment and teach audiences to regard Muslim characters in new ways. Rather than relying on developing existing tropes, movies and television will have to create their own. I would love to believe that there are movie studios and television networks that stand ready to take up Obama’s call for change. But to do right by Muslim Americans, the entertainment industry will have to exhibit greater courage and creativity than it has generally had to offer.