0
Я имею в виду это https://docs.djangoproject.com/en/dev/howto/outputting-pdf/ для генерации PDF с помощью reportlab.Как вывести PDF-файлы с помощью Django?
def some_view(request):
# Create the HttpResponse object with the appropriate PDF headers.
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
# Create the PDF object, using the response object as its "file."
p = canvas.Canvas(response)
# Draw things on the PDF. Here's where the PDF generation happens.
# See the ReportLab documentation for the full list of functionality.
p.drawString(100, 100, "Hello world.")
# Close the PDF object cleanly, and we're done.
logging.debug('-----p---')
logging.debug(p)
p.showPage()
p.save()
return response
Если добавить эту папку ReportLab в MyApp, то он дает эту ошибку:
ViewDoesNotExist at /aps/print-pdf/
Could not import myapp.views. Error was: No module named reportlab
И если я надену эту папку ReportLab из MYAPP папки, то она дает эту ошибку:
ViewDoesNotExist at /aps/print-pdf/
Tried some_view in module myapp.views. Error was: 'HardenedModulesHook' object has no attribute '_files'
Что не так в этом? Пожалуйста помоги.
Как вы установили ReportLab? Вы используете virtualenv? – sneawo