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

吃可爱长大的小学妹 提交于 2019-12-12 02:58:33

问题


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:


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.



来源:https://stackoverflow.com/questions/2503236/django-inline-formset-for-editing-multiple-related-records-at-once-the-right-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!