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 had the same error with boxes.py on macOS Mojave. My solution was to install cairocffi with pip3 and cairo with brew. The two commands fail on their own, but together they work for boxes.py:
cairocffi
pip3
cairo
brew
boxes.py
pip3 install cairocffi brew install cairo