The title of Quentin Tarantino’s latest reflects his obsession with genre movies—in this case, spaghetti westerns in general and Sergio Leone pictures in particular—while also pointing to the writer-director’s penchant for concocting quasi-fantasies that tweak history. “Once Upon a Time in Hollywood” combines his interests in a diffuse, free-association, overlong fairy-tale riffing on things happening in the movie capital fifty or so years ago. Consider it a California-based lesser cousin of “Inglourious Bssterds,” but in this case the mixture of comedy and violence doesn’t come off terribly well.

The centerpiece of the piece is a fictional bromance between Rick Dalton (Leonard DiCaprio), the onetime star of a TV oater called “Bounty Law,” and Cliff Booth (Brad Pitt), who used to be his stunt double but is now just his glorified gofer. Dalton left “Law” to try a big-screen career, but that fizzled, and now he’s relegated to guest spots as villains in other TV series. Booth’s career as a stuntman, meanwhile, collapsed because of his reputation as a literal wife-killer and general troublemaker (as when he had a “friendly” dust-up on the set with Bruce Lee, played as an insufferable self-promoter by Mike Moh)—which poisoned his relationship with a powerful stunt coordinator (Kurt Russell), who, as we see in an opening segment, was once a cowboy star too.

Dalton’s latest gig is on the pilot for the CBS western “Lancer,” in which he plays opposite its up-and-coming stars James Stacy (imitated, not terribly well, by Timothy Olyphant) and Wayne Maunder (mimed even less convincingly by the late Luke Perry), as well as a no-nonsense kid actress (Julia Butters), to whom he pours out his insecurities. After muffing a scene, he recoups to give a performance the cast and crew praise extravagantly. That gives him renewed confidence, and he accepts an offer from an aggressive agent (Al Pacino) to star in some movies in Italy.

Meanwhile Cliff, tooling around L.A. in Dalton’s car while his boss is at work, repeatedly encounters a hot young hippie called Pussycat (Margaret Qualley), to whom he finally gives a ride back to her place. It turns out to be the ranch of old George Spahn (Bruce Dern) where lots of old westerns were shot, in some of which Rick and Cliff performed. It’s now been taken over by Charlie Manson’s (Damon Herriman) “family,” and in forcing them to let him see Spahn, Cliff antagonizes the commune, which includes initially welcoming Gypsy (Lena Dunham), hostile “Squeaky” Fromme (Dakota Fanning) and lanky cowboy Tex Watson (Austin Butler). During the creepy session, Cliff angers the crowd by beating up one of their number (James Landry Hébert) who has slashed a tire on Rick’s car, but drives off before anything can be done about it.

While all that’s happening, we watch as actress Sharon Tate (Margot Robbie) and her husband, director Roman Polanski (Rafal Zawierucha)—who have recently moved into the posh place beside Rick’s house—go out to parties along with their pal, hairdresser Jay Sebring (Emile Hirsch). Sebring, as Steve McQueen (Damian Lewis) helpfully explains while watching them at the Playboy Mansion, was Sharon’s boyfriend before Roman showed up, and is now waiting for the inevitable split-up to catch her on the rebound. We also see Sharon drive to town on her own, buying a first edition of Thomas Hardy’s “Tess of the D’Urbervilles” for Polanski (he’ll eventually adapt it for the screen, of course) and going to a theatre to watch herself in the Dean Martin-as-Matt Helm movie “The Wrecking Crew” and savor the audience reaction.

Six months now pass. Polanski has left for England to scout locations for a new film, and Sharon, heavily pregnant, has invited Roman’s friend Voytek Frykowski (Costa Ronin) and his girlfriend Abigail Folger (Samantha Robinson) to join her and Sebring at the house. Simultaneously Rick and Cliff return from a stay in Italy, where Rick has completed a trio of movies—two westerns and a spy picture—and acquired an Italian wife (Lorenza Izzo). They come home, after a bout of heavy drinking, on the infamous night of August 8, 1969, when Tex arrives in the neighborhood with Manson followers Susan Atkins (Mikey Madison), Patricia Krenwinkle (Madison Beaty) and Linda Kasabian on orders from their leader.

This elaborate conglomeration of fact and fiction gives Tarantino ample opportunity to indulge—or over-indulge—in his personal passions. These include fashioning the look of the picture. He and production designer Barbara Ling have gone to remarkable lengths to recreate the appearance of L.A.in the late sixties. Surviving landmarks—restaurants, theatres, and the like—have been spruced up and put center stage, with the movie marquees, predictably, given special attention. The set decoration mimics the furniture styles of the period, and ostentatiously places typical bric-a-brac and commercial items where the camera can’t miss them. Arianne Phillips’ costumes accentuate the effect, as do the period pop tunes on the soundtrack. And Tarantino obviously has great fun constructing comic scenes from “new old” movies and TV shows, and fiddling with clips from real movies and TV shows of the time by inserting his own stars in them.

The effort extends to the photographic texture. Tarantino doesn’t opt for the 70mm format he employed for “The Hateful Eight” (in a few venues, at least), but he and cinematographer Robert Richardson do go for a widescreen 35mm look, complete with reel changes marked at the upper right of the frame, though whether it will actually be shown in that form in many theatres is doubtful. (Presumably few have the equipment.) It does give the film the feel of a sixties product, though.

What Tarantino does with all this carefully accumulated background, however, is inconsistent. He does manage some excellent sequences. DiCaprio excels in some scenes on the “Lancer” set, particularly that with Butters and one in his trailer after he’s bungled his lines and is furious with himself. Pitt gets his best moments in Cliff’s visit to the Spahn ranch, where Tarantino builds a mood of genuine menace and Pitt and Dern play off nicely against one another. On the other hand, the sequences showing the actual filming of Rick’s “Lancer” scenes are pretty awful, giving no sense of how the process would have occurred and being played turgidly as well. Cliff’s overextended scenes with his dog are also low points. Nonetheless the two actors exhibit real camaraderie throughout, making you believe they’ve depended on another for a long time.

By contrast Robbie isn’t given nearly as much opportunity to shine (except physically, of course), although that trip to “The Wrecking Crew” is a standout. The rest of the large cast is variable: Pacino is larger than life, Butters is amusingly precocious, Qualley paints a portrait of reckless promiscuity, Hirsch has some good moments, and both Butler and Fanning are notable, though in different ways, as Manson’s chief disciples. Many of the others, however, are relegated to blink-and-you’ll-miss-them cameos, while most of those who are playing real people—just like Olyphant and Perry—simply aren’t very convincing.

Flashy but empty, Tarantino’s skewered take on the Hollywood of a half-century ago has some marvelous moments, but drags more often than it soars.