Django Inline formset for editing multiple related

2019-09-18 19:42发布

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

1条回答
我命由我不由天
2楼-- · 2019-09-18 20:12

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.

查看更多
登录 后发表回答