如何在每个分页的“更改列表”上显示超过 100 个项目Django 管理页面?

发布于 2024-08-19 19:50:32 字数 212 浏览 5 评论 0原文

在其中一个模型概述面板中,在按月过滤项目后,我必须选择所有项目,然后创建一个包含有关它们的信息的文档(有点像月度报告)。当 Django 对过滤结果进行分页时,当一个月有超过 100 个项目时,就会出现问题。

有没有办法将显示的项目数从 100 增加到 400 或从过滤结果中选择所有项目?

从一页选择所有项目、创建文档、转到下一页、创建另一个文档等,然后合并文档不是一种选择。

In one of the models overview panel, after I filter the items by month, I have to select them all and then create a document with information regarding them (kind of like a monthly report). This is a problem when one month has more than 100 items as Django paginates the filtering results.

Is there a way to increase the number of items shown from 100 to 400 or select all the items from the filtering result?

Selecting all the items from one page, creating a document, going to the next, creating another, etc, then merging the documents isn't an option.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

前事休说 2024-08-26 19:50:32

请参阅 http://docs.djangoproject .com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_per_page

在您的 ModelAdmin 定义中,设置 list_per_page

class MyModelAdmin(admin.ModelAdmin):
    list_per_page = 400

我相信您还可以添加 < code>all GET 参数添加到您的查询中(即,将 ?all 添加到您的 url 末尾),但这仅在您的项目少于 200 个时有效,并且此限制是硬编码的在管理员中。因此,仅当您的列表数量超过 list_per_page (100) 且少于 200 个项目时,它才有用,但在这种情况下,管理员无论如何都会为您提供一个链接。

See http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_per_page

In your ModelAdmin definition, set list_per_page:

class MyModelAdmin(admin.ModelAdmin):
    list_per_page = 400

I believe you can also add the all GET parameter to your query (ie, add ?all to the end of your url), but that only works if you have less than 200 items, and this limit is hardcoded in the admin. Therefore it's only useful if you have more than list_per_page (100) and less than 200 items, but the admin will offer you a link for this anyway when this is the case.

属性 2024-08-26 19:50:32

如果您正在谈论管理,请参阅

ModelAdmin.list_per_page

If you're talking about admin, see this.

ModelAdmin.list_per_page
贵在坚持 2024-08-26 19:50:32

您应该将 400 设置为 rel= “nofollow noreferrer">list_per_page 如下所示,将每个分页更改列表100(默认)增加到 400强>页面:

# "admin.py"

@admin.register(Person)
class MyModelAdmin(admin.ModelAdmin):
    list_per_page = 400 # Here

You should set 400 to list_per_page as shown below to increase the number of items from 100 (Default) to 400 on each paginated Change List page:

# "admin.py"

@admin.register(Person)
class MyModelAdmin(admin.ModelAdmin):
    list_per_page = 400 # Here
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文