O'Reilly logo

Web Development with Django Cookbook - Second Edition by Aidas Bendoraitis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating PDF documents

Django views allow you to create much more than just HTML pages. You can generate files of any type. For example, you can create PDF documents for invoices, tickets, booking confirmations, and so on. In this recipe, we will show you how to generate resumes (curriculum vitae) in the PDF format out of the data from the database. We will be using the Pisa xhtml2pdf library, which is very practical as it allows you to use HTML templates to make PDF documents.

Getting ready

First of all, we need to install the xhtml2pdf Python library in your virtual environment:

(myproject_env)$ pip install xhtml2pdf

Then, let's create a cv app containing a simple CV model with the Experience model that is attached to it through a foreign key. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required