问题
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