title: Dynamically generate PDF and email it using django
body: <p>I have a django app that dynamically generates a PDF (using reportlab + pypdf) from user input on an HTML form, and returns the HTTP response with an <code>application/pdf</code> MIMEType.</p>
  
  <p>I want to have the option between doing the above, or emailing the generated pdf, but I cannot figure out how to use the EmailMessage class's <code>attach(filename=None, content=None, mimetype=None)</code> method. The <a href="http://docs.djangoproject.com/en/dev/topics/email/#django.core.mail.EmailMessage" rel="noreferrer">documentation</a> doesn't give much of a description of what kind of object <code>content</code> is supposed to be. I've tried a file object and the above <code>application/pdf</code> HTTP response.</p>
  
  <p>I currently have a workaround where my view saves a pdf to disk, and then I attach the resulting file to an outgoing email using the <code>attach_file()</code> method. This seems wrong to me, and I'm pretty sure there is a better way.</p>