How do I allow Puppeteer to access a login-required view in Django?
The simplest way is to render the template yourself, save the output to a temporary static HTML file and open that file with Puppeteer.
You will probably need to adjust the generated HTML to make sure all the static assets are accessible via proper absolute URL and protocol.
My goal here is to use Puppeteer to generate a PDF from a HTML view in Django. Preferably, this happens every time a certain model is saved. The view requires the user to be logged-in and own the model instance used in the view. This, of course, creates problems when trying to launch a Puppeteer instance to access the view and turn it into a PDF -- all I get is a PDF of the login page.
I can think of a few ways, none of which stand out as The Right Way to do things:

Get the users session ID and set the corresponding cookie in Puppeteer, either on the command line or using an environment variable -- I'm not sure this will actually work, I think there are security issues and as I'd like to do this in the model.save() method I don't necessarily have access to the user session ID.
Make the view require login only when not accessed from localhost -- this seems like a security issue.

Other ways to do this would be to use a HTML-to-PDF library, but these come with a lot of limitations on the HTML/CSS they can understand, or to draw the PDF directly using reportlab without going through the intermediate HTML stage.
Any ideas or solutions I'm missing?