ricco386 / django-faktura

Simple django app for invoice generation.
MIT License
12 stars 6 forks source link

AttributeError at /invoices/<id_invoice>/download/ #15

Closed pceuropa closed 3 years ago

pceuropa commented 4 years ago

After click on download PDF i've received

` Request Method: GET

http://127.0.0.1:8000/invoices/1786f85d-47d9-4a08-8852-3104227ba7bb/download/ 3.1 AttributeError 'NoneType' object has no attribute 'endswith' /home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/wkhtmltopdf/utils.py, line 296, in make_absolute_paths /home/m/Desktop/localhost/django-tt/venv/bin/python3 3.8.2 ['/home/m/Desktop/localhost/django-tt/project', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages'] Thu, 27 Aug 2020 12:11:58 +0000 `


Request Method: GET
Request URL: http://127.0.0.1:8000/invoices/1786f85d-47d9-4a08-8852-3104227ba7bb/download/

Django Version: 3.1
Python Version: 3.8.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'faktura']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 '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']

Traceback (most recent call last):
  File "/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 202, in _get_response
    response = response.render()
  File "/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/wkhtmltopdf/views.py", line 73, in rendered_content
    return render_pdf_from_template(
  File "/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/wkhtmltopdf/utils.py", line 201, in render_pdf_from_template
    input_file = RenderedFile(
  File "/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/wkhtmltopdf/utils.py", line 178, in __init__
    self.temporary_file = render_to_temporary_file(
  File "/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/wkhtmltopdf/utils.py", line 331, in render_to_temporary_file
    content = make_absolute_paths(content)
  File "/home/m/Desktop/localhost/django-tt/venv/lib/python3.8/site-packages/wkhtmltopdf/utils.py", line 296, in make_absolute_paths
    if not x['root'].endswith('/'):

Exception Type: AttributeError at /invoices/1786f85d-47d9-4a08-8852-3104227ba7bb/download/
Exception Value: 'NoneType' object has no attribute 'endswith'
pceuropa commented 4 years ago

OK i found solution on https://stackoverflow.com/questions/24071290/generating-pdf-with-wkhtmltopdf-django by add STATIC_ROOT = '/static/'

ricco386 commented 3 years ago

Thanks for reporting the bug. I have updated the README with instruction, for anyone else having this issue.