I've got this function
image = settings.STATIC_ROOT+'/img/logo_facture.png'
context = {
[...]
'image': image,
}
html = template.render(context)
pdf = render_to_pdf(path_pdf, context)
if pdf:
response = HttpResponse(pdf, content_type='application/pdf')
filename = type_pdf + "_%s_%s.pdf" % (commande.id, commande.date.strftime('%Y'))
content = "inline; filename=%s" % filename
download = request.GET.get("download")
if download:
content = "attachment; filename=%s" % filename
response['Content-Disposition'] = content
return response
return HttpResponse("Not found")
on my pdf.html template somewhere on this webpage i've got this img tag
<img src="{% static '/img/logo_facture.png' %}" height="116" width="330" alt="image non chargée" />
but nothing appear on my PDF downloaded ... I tried with {{ STATIC_ROOT }} ... with "/home/Pseudo/project/static/img/logo_facture.png, I tried with https://Pseudo.pythonanywhere.com... (absolute path) ... I tried to with image var in context .. Still no image on my PDF downloaded :( ... On local it's works ^^
I applied all settings into web settings on pythonanywhere ...
If someone has a solution ... another PDF converter library to use ?
Thanks for your help ;)