django-weasyprint
Django WeasyPrint integration
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive license. It is a straightforward, well-tested integration layer for a common need (PDF generation from Django templates). Install it if you need to generate PDFs from Django views or templates.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Django 3.2 or later and Python 3.10 or later.
- WeasyPrint may require system libraries for font and image rendering depending on your platform.
- Low friction install with WeasyPrint bundled as a dependency.
License · maintenance · safety
Apache-2.0 (permissive) — Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.
last release 2026-04-10 (126 days) · last repo commit 2026-07-01 · 402 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 248,426 downloads/mo, #8,666 on PyPI
Alternatives
Verify before relying
pip install django-weasyprint
from django_weasyprint import WeasyTemplateResponseMixin
from django.views.generic import DetailView
class MyPDFView(WeasyTemplateResponseMixin, DetailView):
template_name = 'mymodel.html'
pdf_filename = 'output.pdf'- Whether WeasyPrint's switch to pydyf in version 53 (from Cairo) affects PDF output quality or rendering for your use case.
- System-level dependencies needed for WeasyPrint on your target deployment platform.
What it is and what it does
Django-WeasyPrint bridges Django's template system with WeasyPrint, a Python library that converts HTML and CSS into PDF documents. It provides both a class-based view mixin (`WeasyTemplateResponseMixin`) and a standalone response class (`WeasyTemplateResponse`) that handle the boilerplate of rendering a Django template to HTML, then converting that HTML to PDF. You use it by inheriting from the mixin in your view, optionally configuring PDF-specific settings like filename and attachment behavior, and the view automatically returns a PDF response instead of HTML.
The package handles URL fetching for resources like stylesheets and images through a customizable `DjangoURLFetcher` that understands Django's static files and URL schemes. It supports both inline PDF display and download-dialog attachment modes, PDF options (like accessibility variants), and dynamic filename generation. The integration is minimal—most of the heavy lifting is delegated to WeasyPrint itself, which means you write standard Django templates and CSS, then get PDFs without extra conversion steps.
Use it for
- Generate invoices or receipts as PDF downloads from Django template-based views.
- Create printable reports or data exports from Django querysets rendered as styled HTML.
- Build PDF certificates or documents dynamically based on user data in a DetailView.
- Serve inline PDF previews in a web interface without leaving Django.
- Generate PDFs asynchronously in Celery tasks using WeasyPrint's HTML and write_pdf methods.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive license. It is a straightforward, well-tested integration layer for a common need (PDF generation from Django templates). Install it if you need to generate PDFs from Django views or templates.
Install
django-weasyprint on PyPI
Before you install
Low friction install with WeasyPrint bundled as a dependency. Actively maintained with recent commits; last release 126 days ago. Supports current Python versions (3.10–3.14) and Django versions through 6.0.
Requires Django 3.2 or later and Python 3.10 or later. WeasyPrint may require system libraries for font and image rendering depending on your platform.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install django-weasyprint
from django_weasyprint import WeasyTemplateResponseMixin
from django.views.generic import DetailView
class MyPDFView(WeasyTemplateResponseMixin, DetailView):
template_name = 'mymodel.html'
pdf_filename = 'output.pdf'
Verify before relying
- Whether WeasyPrint's switch to pydyf in version 53 (from Cairo) affects PDF output quality or rendering for your use case.
- System-level dependencies needed for WeasyPrint on your target deployment platform.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesDjangoWeasyPrint |
| Maintenance | Actively maintained 126 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 248,426 / month, #8,666 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 3.2Framework :: Django :: 4.2Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Software Development :: Libraries :: Python Modules |
Evidence: django_weasyprint-2.5.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “weasyprint django integration”
- django-weasyprintProvides Django class-based views and response classes for generating…
- weasyprintWeasyPrint converts HTML and CSS into PDF documents using a…
- mkdocs-with-pdfGenerates a single PDF file from an MkDocs documentation site, with…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also weasyprint · md2pdf · mkdocs-with-pdf · django-extra-views · xhtml2pdf · pydyf · django-braces · django-wkhtmltopdf · pdfkit · fpdf