Skip to content
Advertisement

Generate PDF from html template and send via Email in Django

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:

JavaScript

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 code now it’s generating pdf and sending an email but when I open attached pdf file from recieved email it says unsupported file formate data.

Here’s the updated Code:

JavaScript

Help me, please!

Thanks in advance!

Advertisement

Answer

Here’s the complete working version of above code:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement