Is there a way to convert django-filter result to pdf

78 Views Asked by At

I am using Django-filter to filter out data and export to csv table I want to export the same data to pdf but I am having trouble using xhtml2pdf and reportlab

This is what I have tried with xhtml2pdf.

here is the view:

def pdfview(request):
    user=User.objects.all()

    govFilter=GovFilter(request.GET, queryset=user)
    user=govFilter.qs

    template=render_to_pdf('staff/pdf_template.html')
    # context={'user':user}
    html=template.render(context)

    response=HttpResponse(content_type='application/pdf')
    response['Content-Disposition']='attachment; filename="report.pdf"'
    generate_pdf(html,file_object=response)

    return response

this is the error.

AttributeError at /pdfview/
'str' object has no attribute 'user'

0

There are 0 best solutions below