This is my view:
from django.conf import settings from django.http import HttpResponse from django.template.loader import render_to_string import weasyprint
I solve this problem by following this link: https://github.com/Kozea/WeasyPrint/issues/79