Django / Django-easy-pdf : 'NoneType' Object Has No Attribute 'encode'
I'm trying to get django-easy-pdf to work, but am receiving this error: Environment: Request Method: GET Request URL: http://localhost:8001/lld/tesco-greenfield-datacenter-deploy
Solution 1:
I can't even believe I've spent a few days crying and tearing my hair out because I was using a Google font. Yep, once I removed <link href="http://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet" type="text/css">
from my template, the error vamoosed!
Solution 2:
After dig in xhml2pdf I saw @RMPhoenix is right the only solution (for now) is remove the CSS causing this error. The traceback clearly shows that CSS parser raise an error.
But the more relevant is I think this piece of code:
xhtml2pdf/parser.py in pisaParser at line 711:
if default_css:
context.addDefaultCSS(default_css)
pisaPreLoop(document, context)
#try:
context.parseCSS()
#except:
# context.cssText = DEFAULT_CSS
# context.parseCSS()
# context.debug(9, pprint.pformat(context.css))
pisaLoop(document, context)
Post a Comment for "Django / Django-easy-pdf : 'NoneType' Object Has No Attribute 'encode'"