Grease a 9-inch cake pan with olive oil. Set aside.
In a large stock pot or dutch oven, bring the milk and water/stock to a simmer over high heat. When bubbles begin to form, whisk in the polenta in a gentle stream, and turn the heat down to medium-low. Simmer, stirring constantly, until the polenta is thick but still smooth, about 10 minutes. Add the salt and 1 tablespoon olive oil. Continue to stir until the polenta is resisting your whisk and forms a clump inside of it, about 3 to 5 minutes more.
Working quickly, spoon the polenta into the prepared pan and smooth it evenly, pressing some of the mixture up the sides. Place a loose sheet of plastic wrap over it, then use a 1-cup measure to smooth the bottom and press the polenta up the sides of the pan, making sure to still have some slope. The bottom crust and side walls should all be about 1/2 inch thick. You don't have to go all the way up the sides of the pan, just shy of an inch tall.
Refrigerate the polenta crust for at least 2 hours, or overnight.
Preheat the oven to 450 degrees. Bake the chilled polenta in the oven for 3o to 40 minutes, until crispy and beginning to brown around the edges. Remove from the oven.
Spoon the sauce into the prepared crust and use the back of your spoons to smooth it into an even layer. Arrange the cheeses on top, followed by the onions. Dot the top of the pie with the pesto. Season lightly with salt and pepper.
Return the pie to the oven and bake until the cheese is melted and bubbling and the onions are beginning to brown, about 10 to 15 minutes. Serve immediately, straight from the pan.