Django HTML в pdf не отображается, когда цикл for loop длиннее 1 страницы
Примечание: html-верстка в pdf отлично отображается, если объект, переданный в функцию pdf не превышает размер одной страницы. Забавно, но когда я удаляю стилизацию из html, он работает, и под работой я имею в виду рендеринг в pdf и создание нескольких страниц... но теперь очевидно, без стилизации!
HTML КОД
Views.py
def downloadPDF(request, pk):
queryOrderPlan = OrderPlan.objects.get(id=pk)
queryItems = queryOrderPlan.orderitem_set.all()
name = queryOrderPlan.order_number
date = timezone.now()
count = queryItems.count()
cb_data = {"queryItems": queryItems, "date": date, "count": count,
"queryOrderPlan": queryOrderPlan
}
pdf = render_to_pdf('orderApp/pdfs/itempdf.html', cb_data)
if pdf:
response = HttpResponse(pdf, content_type='application/pdf')
content = "filename=%s " % (name)
response['Content-Disposition'] = content
return response
utils.py
def render_to_pdf(template_src, context_dict={}):
template = get_template(template_src)
html = template.render(context_dict)
result = BytesIO()
pdf = pisa.pisaDocument(BytesIO(html.encode("ISO-8859-1")), result)
if not pdf.err:
return result.getvalue()
return HttpResponse(result.getvalue(), content_type='application/pdf')
return None