diff --git a/osinaweb/billing/__pycache__/urls.cpython-310.pyc b/osinaweb/billing/__pycache__/urls.cpython-310.pyc index f1898f91..dfe42e93 100644 Binary files a/osinaweb/billing/__pycache__/urls.cpython-310.pyc and b/osinaweb/billing/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/billing/__pycache__/views.cpython-310.pyc b/osinaweb/billing/__pycache__/views.cpython-310.pyc index e0ac4cb8..70bf2185 100644 Binary files a/osinaweb/billing/__pycache__/views.cpython-310.pyc and b/osinaweb/billing/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/billing/templates/invoice-details.html b/osinaweb/billing/templates/invoice-details.html index 5ae80e2f..ce498023 100644 --- a/osinaweb/billing/templates/invoice-details.html +++ b/osinaweb/billing/templates/invoice-details.html @@ -13,11 +13,11 @@
- +

Bill To: Winabig

-

Customer Details: 036466464

+

Customer Details: 036466464

diff --git a/osinaweb/billing/views.py b/osinaweb/billing/views.py index 468230f9..7b5b3223 100644 --- a/osinaweb/billing/views.py +++ b/osinaweb/billing/views.py @@ -2,11 +2,11 @@ from django.shortcuts import render, get_object_or_404 from django.utils import timezone from datetime import timedelta from .models import * -from django.http import JsonResponse -from django.http import HttpResponse +from django.http import JsonResponse, HttpResponse from django.template.loader import get_template from weasyprint import HTML + # LISTING def items (request, *args, **kwargs): context = { @@ -114,14 +114,11 @@ def invoice_details (request, invoice_id): def generate_pdf(request): - # Render the template - template = get_template('invoice.html') - html = template.render() - - # Create a PDF file - pdf_file = HTML(string=html).write_pdf() - - # Prepare HTTP response - response = HttpResponse(pdf_file, content_type='application/pdf') - response['Content-Disposition'] = 'filename="invoice.pdf"' - return response + template = get_template('invoice-details.html') + context = {} + html_string = template.render(context) + + pdf = HTML(string=html_string).write_pdf() + response = HttpResponse(pdf, content_type='application/pdf') + response['Content-Disposition'] = 'attachment; filename="my_pdf.pdf"' + return response \ No newline at end of file diff --git a/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc index 4e5439e8..b6dc4773 100644 Binary files a/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc and b/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc differ