Skip to content

PDF Views for Models

Compare
Choose a tag to compare
@donhauser donhauser released this 02 Aug 10:29
· 52 commits to main since this release

Version 0.2 of wagtail-pdf-view brings support for rendering PDF views of models.

Use-cases include:

  • rendering customer invoices
  • creating participation lists of members in your organization
  • rendering tickets
  • and many more!

Since models do not use wagtails draft system, there are no previews for the model PDFs.
Unlike PDF view pages, PDF rendered models are useful for rather simple content, or for generated content.

This version offers you three different ways to include the rendered PDF models in your page

  • /admin restricted content, managed by ModelAdmin
  • public content, managed by ModelAdmin
  • public content, the view is directly embedded in your urls.py

Version changes:

  • PdfModelMixin implements basic functionalities needed to render a model as PDF
  • New file modeladmin/mixins.py:
    • ModelAdminPdfViewMixin automatically create a public view for the inheriting model (with action 'live')
    • ModelAdminPdfAdminViewMixin automatically create a /admin restricted view for the inheriting model (with action 'pdf')
    • ExtendableButtonHelperMixin allows to append custom buttons to ModelAdmins ButtonHelper easier
    • CustomActionPermissionHelperMixin implements generalized permission check function user_can_perform_action()
  • The new file urls.py loads URLs from the new wagtail hook register_pdf_site_urls
  • AdminViewMixin can be used to require view permissions on a model
  • WagtailTexAdminView and WagtailWeasyAdminView implement the restricted views for tex and Weasyprint
  • The more customized class PDFDetailView extends the inheritance from BaseDetailView in WagtailTexView and WagtailWeasyView
  • HTTP-Content from PdfViewPageMixin.serve_pdf() moved to PDFDetailView

Bugfixes:

  • Reversing URLs is now fixed (MultipleViewPageMixin.__init_subclass__() was extended)