用于一次编辑多个相关记录的 Django 内联表单集 - 正确的方法?

发布于 2024-08-26 06:37:31 字数 165 浏览 4 评论 0原文

使用内联表单集时,如何进行分页?我正在使用 django 1.1。 我所处的情况是,用户需要能够快速轻松地编辑相关对象(这就是为什么我认为我应该使用内联表单集)。但是,可能有一百多个对象需要编辑,这会产生相当大的表单集,因此分页是有意义的。

有更好的方法来做到这一点吗?

谢谢 伯特

When using inline formsets, how does one do paging? I'm using django 1.1.
The situation I'm in, is that the user needs to be able to edit the related objects quickly and easily (which is why I think I should be using an inline formset). However, there can be a more than a hundred objects to edit, which makes a pretty large formset, so paging would make sense.

Is there a better way to be doing this?

Thanks
Bert

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

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

发布评论

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

评论(1

蝶…霜飞 2024-09-02 06:37:31

不幸的是我无法让分页与表单集一起使用。

相反,我扩展了 BaseInlineFormSet 并更改了 get_queryset 方法,以仅返回需要编辑的对象的子集,并对返回的最大对象数量设置限制。因此,当用户想要编辑相关对象时,他们一次只能编辑一定数量的对象,例如可能的 60 个对象中的 20 个。当用户完成前 20 个编辑并提交表单时,将显示下一个 20 个。

Unfortunately I couldn't get paging to work with formsets.

Instead I extended BaseInlineFormSet and changed the get_queryset method to return only a subset of the objects that were needed to be edited and set a limit on the maximum number of objects returned. So when the user wants to edit related objects, they can only edit a set number of objects at a time e.g. 20 of the possible 60.When the user has completed editing the first 20, and submits the form, the next 20 will be displayed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文