/ExportToPDF-Django

A simple implementation for exporting PDFs from Django Admin Panel

Primary LanguagePython

ExportToPDF-Django

📝 Description

While the Django-Import-Export Library supports the export of records in CSV, XLS, HTML and many other formats directly from the Django Admin Panel, there is no Library to export the records in PDF format. This can be a common use case in many kinds of forms.

So, the ExportToPDF-Django Repository demonstrates a simple yet useful way to export records in PDF format without the use of any Third Party Library.

⚙️ How To Use

  1. Installation (Inside your Python Virtual Environment) :
pip install -r requirements.txt
  1. Setting up Django Project :
python manage.py makemigrations
python manage.py migrate
python manage.py runserver

Now you can access the Form at 127.0.0.1:8000 and the Admin Panel at 127.0.0.1:8000/admin

🎥 Video Demo

Demo.mp4

💡 How to Customize the Generated PDF

You can style the PDF just like an HTML page by editing the pdfs.html and pdfstyle.css files!

This is possible because we are just passing a QuerySet of the selected records from the Admin Panel to an HTML page and then using the Browser's default PDF print feature ( window.print() )