开发者

Django Inline formset for editing multiple related records at once - the right way to go?

开发者 https://www.devze.com 2022-12-23 18:11 出处:网络
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 thin

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 开发者_JS百科this?

Thanks Bert


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消