This is my view:
from django.conf import settings from django.http import HttpResponse from django.template.loader import render_to_string import weasyprint
This was solved for me by installing the following dependencies on Ubuntu:
sudo apt-get install libpango1.0-0 sudo apt-get install libcairo2 sudo apt-get install libpq-dev
Check out the dependencies at the link:
http://weasyprint.readthedocs.io/en/latest/install.html