fix: path to pdf file
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import io
|
||||
from pathlib import Path
|
||||
|
||||
from django.contrib.staticfiles import finders
|
||||
from django.core.files import File
|
||||
from pypdf import PdfReader, PdfWriter
|
||||
|
||||
@@ -46,8 +46,8 @@ def generate_rental_pdf(rental: Rental) -> bool:
|
||||
)
|
||||
|
||||
# Write data in pdf
|
||||
pdf_path = Path(Path(__file__).parent) / "static/rental/Verleihformular.pdf"
|
||||
reader = PdfReader(pdf_path)
|
||||
pdf_path_str = finders.find("rental/Verleihformular.pdf")
|
||||
reader = PdfReader(pdf_path_str)
|
||||
writer = PdfWriter()
|
||||
writer.append(reader)
|
||||
|
||||
@@ -57,7 +57,8 @@ def generate_rental_pdf(rental: Rental) -> bool:
|
||||
)
|
||||
|
||||
with io.BytesIO() as bytes_stream:
|
||||
writer.write(bytes_stream)
|
||||
writer.write(bytes_stream)
|
||||
bytes_stream.seek(0)
|
||||
|
||||
# Save pdf in rental
|
||||
rental_name = f"Verleihformular-{str(rental.pk).zfill(4)}.pdf"
|
||||
|
||||
Reference in New Issue
Block a user