django - 打印多页
目前,我在模型管理中列出了我的所有“项目”。我已将 ModelAdmin.list_per_page 设置为 50,我的列表分为 8 页。但是,如果我需要打印整个列表,我必须单击每一页,然后打印网页。
我可以为同一模型创建第二个 modeladmin,以便在需要打印时可以获得更大的 list_per_page 值吗?
有更好的方法吗?
任何想法表示赞赏 谢谢
Currently i have a listing of all of my "projects" in a modeladmin. i have set ModelAdmin.list_per_page to 50 and my listing is split in 8 pages. However if i need to print the whole list i have to click each page and then print the webpage.
can i create a second modeladmin for the same model so i can have a greater list_per_page value when i need to print?
Is there a better way to do it?
any idea is appreciated
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我而言,每个模型只能有一个
ModelAdmin
。您可以将
?all
添加到地址栏中的 url 以列出所有项目,让您的生活更轻松,但不幸的是,这只适用于一定数量的项目(我猜是 200 个)。您还可以考虑将每页的项目数量增加到一个可以在浏览器中浏览的便利性和打印的便利性之间取得良好平衡的数字。
但是,根据您想要打印页面的原因,我建议您在网站中创建一个视图,以生成轻松打印所需的表格。这也允许您在打印中添加一些额外的参数,例如打印日期(尽管您的浏览器也可能将其放在某个地方)。
您还可以考虑生成 pdf 文件或类似文件。
As far as I'm concerned, only one
ModelAdmin
per model is possible.You could add
?all
to the url in address bar to list all items to make your life a bit easier, but this unfortunately only works up to a certain total amount of items (200 I guess).You might also consider increasing the number of items per page to a number that is a good balance between the convenience of browsing it in your browser and printing it.
However, depending on the reason you want to print the page, I would suggest you create a view in your website that generates the required table for easy printing. That allows you to add some extra parameters to your print too, like the printing date (although your browser might put it somewhere too).
You could also consider generating a pdf file, or something like that.