title: Attaching pdf's to emails in django
body: <p>My app produces pdf reports using django-wkhtmltopdf. I want to be able to attach the pdf to an email and send.</p>
  
  <p>Here is my pdf view:</p>
  
  <pre><code>class Report(DetailView):
      template = 'pdf_reports/report.html'
      model = Model
  
      def get(self, request, *args, **kwargs):
          self.context['model'] = self.get_object()
  
          response=PDFTemplateResponse(request=request,
                                       template=self.template,
                                       filename ="report.pdf",
                                       context=self.context,
                                       show_content_in_browser=False,
                                       cmd_options={'margin-top': 0,
                                                    'margin-left': 0,
                                                    'margin-right': 0}
                                       )
          return response
  </code></pre>
  
  <p>And here is my email view:</p>
  
  <pre><code>def email_view(request, pk):
      model = Model.objects.get(pk=pk)
      email_to = model.email
      send_mail('Subject here', 'Here is the message.', 'from',
      [email_to], fail_silently=False)
  
      response = HttpResponse(content_type='text/plain')
      return redirect('dashboard')
  </code></pre>