Skip to content
This repository was archived by the owner on Jul 5, 2019. It is now read-only.

Latest commit

 

History

History
53 lines (34 loc) · 1.14 KB

README.rst

File metadata and controls

53 lines (34 loc) · 1.14 KB

django-weasyprint

A Django class-based view generating PDF responses using WeasyPrint.

Installing

Install and update using pip:

pip install -U django-weasyprint

Usage

Use WeasyTemplateView as class based view base class or the just the mixin WeasyTemplateResponseMixin on a TemplateView (or subclass thereof).

Example

from django.conf import settings
from django.views.generic import DetailView

from django_weasyprint import WeasyTemplateResponseMixin


class MyModelView(DetailView):
    model = MyModel
    template_name = 'mymodel.html'


class MyModelViewPrintView(WeasyTemplateResponseMixin, MyModelView):
    pdf_stylesheets = [
        settings.STATIC_ROOT + 'css/app.css',
    ]

Links