def send_invoice(invoice): # Initialize message on creation. message = EmailMessage('base/mail/invoice.html', {'invoice': invoice}, invoice.seller.email, to=[invoice.buyer.email]) message.attach_file(invoice.document.path) # Send message when ready. It will be rendered automatically if needed. message.send()