title: Attach img file in PDF Django Weasyprint
body: <p><strong>Hello friends</strong></p>
  
  <p>I want to ask you for help.</p>
  
  <p>I need help with attach img file in pdf we use WeasyPrint for generation pdf from html.</p>
  
  <p>I don't know where to add <code>base_url=request.build_absolute_uri()</code> to tasks.py.  Where in the file tasks.py ?</p>
  
  <p>Now instead of images is empty place.</p>
  
  <p>I try my best but i don't succeed. So please help.</p>
  
  <p><strong>html file</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  {% load static %}
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div&gt;
          &lt;img src="{% static 'images/static.jpg' %}" alt=""&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>tasks.py</strong></p>
  
  <pre><code>from celery import task
  from django.shortcuts import get_object_or_404
  from oferty.models import Order
  from django.template.loader import render_to_string
  from django.core.mail import EmailMultiAlternatives
  from django.conf import settings
  import weasyprint
  from weasyprint import default_url_fetcher, HTML
  from io import BytesIO
  
  @task
  def order_created(order_id):
      """
      Task to send an e-mail notification when an order is successfully created.
      """
      order = Oferta.objects.get(id=order_id)
      subject = 'xxx nr {}'.format(order.id)
      html_content = '&lt;p&gt;&lt;strong&gt;Hallow, {}!&lt;/p&gt;&lt;/strong&gt;&lt;br&gt;&lt;p&gt;
      email = EmailMultiAlternatives(subject,
                                     html_content,'admin@xxx.com',
                                     [order.email])
  
      # generation PDF.
      html = render_to_string('order/order/pdf.html', {'order': order})
      out = BytesIO()
      stylesheets = [weasyprint.CSS(settings.STATIC_ROOT + 'css/pdf.css')]
  
      weasyprint.HTML(string=html).write_pdf(out,
                                             stylesheets=stylesheets)
      # attach PDF.
      email.attach('order_{}.pdf'.format(order.id),
                   out.getvalue(),
                   'application/pdf')
  
      email.attach_alternative(html_content, "text/html")
      email.send()
  </code></pre>
  
  <p>I would appreciate your help</p>