5đź‘Ť
âś…
Assuming your queryset
variable contains all the records you need, you could insert a PageBreak
object. Just add from reportlab.platypus import PageBreak
to the top of your file, then append a PageBreak
object to your document’s elements.
If you want to change the template for each page, you can also append a NextPageTemplate
and pass the id
of your PageTemplate
. You’ll need to add from reportlab.platypus import NextPageTemplate
to the top of your file as well.
for obj in queryset:
#1st frame
model = Paragraph(obj.make,styles["Verdana9"])
story.append(model)
modelfr.addFromList(story,c)
#2nd frame
signatory = Paragraph(obj.signatory,styles["VerdanaB10"])
story.append(signatory)
signfr.addFromList(story,c)
# Force the report to use a different PageTemplate on the next page
story.append(NextPageTemplate('rsl_frame2'))
# Start a new page for the next object in the query
story.append(PageBreak())
You could move the PageBreak
wherever you need it, but it’s a simple “function” flowable. NextPageTemplate
can take the id
of any valid PageTemplate
object that you’ve added via addPageTemplates
.
👤Nitzle
Source:stackexchange.com