I’m trying to generate a pdf file from an HTML template using Weasyprint python package and I need to send it via email using. Here’s what i have tried: But it returns an error as TypeError: expected bytes-like object, not HttpResponse How can I generate and send a pdf file to an email from HTML template? Update: With this updated