I'm trying to create a pdf with this library implementing the most simple example of de docs
using the url and render directly from the template like this
url(r'^pdf/$', PDFTemplateView.as_view(template_name='my_template.html',
filename='my_pdf.pdf'), name='pdf'),
this is the html of the template file
<!DOCTYPE html>
<html>
<head>
<title>Hello Wold</title>
</head>
<body>
<p>My First Pdf</p>
</body>
</html>
but when i try the url the error is this
AttributeError at /pdf/ 'NoneType' object has no attribute 'endswith'
how can i fix it
this is the Traceback
Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 139. response = response.render() File "/usr/local/lib/python2.7/dist-packages/django/template/response.py" in render 105. self.content = self.rendered_content File "/usr/local/lib/python2.7/dist-packages/wkhtmltopdf/views.py" in rendered_content 123. delete=(not debug) File "/usr/local/lib/python2.7/dist-packages/wkhtmltopdf/views.py" in render_to_temporary_file 78. content = make_absolute_paths(content) File "/usr/local/lib/python2.7/dist-packages/wkhtmltopdf/utils.py" in make_absolute_paths 151. if not x['root'].endswith('/'):
Exception Type: AttributeError at /pdf/ Exception Value: 'NoneType' object has no attribute 'endswith'
Environment:
Request Method: GET
Django Version: 1.6.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
'rest_framework',
'cian',
'django_extensions',
'wkhtmltopdf')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
this is the screenshot with the django-wkhtmltopd error
Looks like you have a problem with your root path. Try settings STATIC_URL in Django setting file (settings.py)