i am working on an django App
On my html page " results.html " i want to add a button to download the page to pdf
How is it possible, please ? What i have to write in the fonction" download_pdf" in the file views.py?
.html :
<a href="{% url 'download_pdf' %}" role="button">Download pdf</a>
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.home),
path('views.download_my_pdf', views.download_pdf, name="download_pdf"),
]
views.py :
def download_pdf(request):
return response
CodePudding user response:
You can convert a HTML page to a PDF on-the-fly and send its result as a response in Django with Django Weasyprint. E.g., have a look at the examples with WeasyTemplateResponseMixin
.