django-easy-pdf icon indicating copy to clipboard operation
django-easy-pdf copied to clipboard

Render dynamic template before creating pdf view

Open MisterNox opened this issue 5 years ago • 0 comments

Cool project! Right now I am facing the problem, that I need to render the template file including the request parameter before creating the pdf view as my template file contains some dynamic content (DTL) based on some profile attributes of the the user currently logged in. How do I have to change the function? Right now it looks like this:

class TeamPDFView(PDFTemplateView):
    template_name = 'pdf.html'
    base_url = 'file://' + settings.STATIC_ROOT
    download_filename = 'hello.pdf'
    def get_context_data(self, **kwargs):
        return super(TeamPDFView, self).get_context_data(
            pagesize='A4',
            title='Hi there!',
            **kwargs
        )

This works, but with an empty pdf, because of the dynamic content. Thank you very much for your help.

MisterNox avatar Apr 28 '19 19:04 MisterNox