Answer the question
In order to leave comments, you need to log in
How to split long text into pages?
I have a small django site with very long text on the main page. Text is added via the admin using django-flatblocks . Is it possible to divide this large block of text into pages and make pagination?
I'm new to python/django but I think you can just make a separate model for this page, add text piece by piece and then render page by page. But it still seems to me that this is not entirely correct, and it is better to automatically divide a large block of text into parts and display it. But I dont know how.
Answer the question
In order to leave comments, you need to log in
Programmatically, you can count the number of characters or words. And cut on them [:1000], [1001:2000], ...
But here is a double-edged sword. If the text is stored in the database with html tags, then there may be a jamb. When the tag opens on the first page and closes on the second.
Ideally, add a marker or a special tag that you yourself will manually insert into the text and it will be paginated. Then there will be no problems with html tags.
In any case, write your own paginator or look for a ready-made solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question