Django WeasyPrint CBV
Project description
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 CONTENT_TYPE_PNG, WeasyTemplateResponseMixin
class MyModelView(DetailView):
# vanilla Django DetailView
model = MyModel
template_name = 'mymodel.html'
class MyModelPrintView(WeasyTemplateResponseMixin, MyModelView):
# output of DetailView rendered as PDF
pdf_stylesheets = [
settings.STATIC_ROOT + 'css/app.css',
]
class MyModelImageView(WeasyTemplateResponseMixin, MyModelView):
# generate a PNG image instead
content_type = CONTENT_TYPE_PNG
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django_weasyprint-0.5.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10cf8d134f5ef54a79f017a651d477da937a6798cf6f4c2bed2669af76785e9d |
|
MD5 | 023ffada08e16fd40fdf23d2a7311beb |
|
BLAKE2b-256 | f4bc07e80c8fd18cb9b0ae7d193f2e4e5d1b4c650b9cdf64eb6bdb3f06949112 |