From 50ec619416f45604d0b7962d1b922e5dc88a241b Mon Sep 17 00:00:00 2001 From: Guilherme Vierno Date: Fri, 30 May 2014 15:40:52 -0300 Subject: [PATCH] Updates the README with a CBV example. --- README.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.rst b/README.rst index 544b42f..3008ca0 100644 --- a/README.rst +++ b/README.rst @@ -22,3 +22,18 @@ Simply do the following:: result = generate_pdf('my_template.html', file_object=resp) return result +Class-based views +================= + +You can use the provided PdfMixin with any view that subclasses TemplateView, +example:: + + from django.views.generic.detail import DetailView + from django_xhtml2pdf.views import PdfMixin + from .models import Product + + class ProductPdfView(PdfMixin, DetailView): + model = Product + template_name = "product_pdf.html" + +It will output the rendered content of the view in pdf.