Я установила пакет weasyprint согласно инструкции (проект Django)
https://simpleisbetterthancomplex.com/tutorial/201...
Ошибка выпадает:
OSError at /tyforindividuals/newty
cannot load library 'gobject-2.0-0': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0-0'
from django.core.files.storage import FileSystemStorage
from django.http import HttpResponse
from django.template.loader import render_to_string
from weasyprint import HTML
def html_to_pdf_view(request):
par = ['a', 'b', 'c']
html_string = render_to_string('my.html', {par})
html = HTML(string=html_string)
html.write_pdf(target='/tmp/mypdf.pdf')
fs = FileSystemStorage('/tmp')
with fs.open('mypdf.pdf') as pdf:
response = HttpResponse(pdf, content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="mypdf.pdf"'
return response