django-bakery icon indicating copy to clipboard operation
django-bakery copied to clipboard

Could the BuildableListView work with pagination?

Open palewire opened this issue 11 years ago • 4 comments

palewire avatar Aug 19 '14 22:08 palewire

I looked into pagination today, and I've put some ideas about how it could be implemented in a pagination branch.

Paginating results with BuildableListView seems like low-hanging fruit because that functionality is built right into the MultipleObjectMixin. However, the user has to specify the page parameter inside the URLconf instead of as a GET request parameter, e.g. /objects/page1 instead of /objects/?page=1.

I was able to bake these pages by overriding build_method. If an instance of BuildableListView has a valid paginate_by member, then the Paginator class determines how the queryset should be partitioned. For each page of data, it modifies build_path and the value of page_kwarg before calling the super build_method to build the page as usual.

Example App ran smoothly with runserver and when I started serving the .build with http-server. But, the paginating links in the template didn't work when I ran the projecton buildserver.

@palewire, what are your thoughts?

steve-kasica avatar Apr 14 '17 22:04 steve-kasica

I took another look at this issue, and I refactored my POC from April against the latest code changes in this commit. The most significant difference is using reverse to assign build_path, which is nice because then a build_path member isn't a required attribute. I'm ready to create a pull request. But, I'm curious about how you'd want to implement these changes.

Do you see this kind of enhancement directly modifying the build_queryset method of BuildableListView or should it be included a mixin, like how BuildableTemplateView supports JSON responses?

steve-kasica avatar Sep 08 '17 23:09 steve-kasica

Thanks for this. I'll give it a look when I have some time. I've experimented with using reverse myself so I like this direction, though I haven't given it a close look yet.

palewire avatar Sep 11 '17 15:09 palewire

@swkasica I'm still open to this patch if you ever have the time.

palewire avatar Dec 05 '18 03:12 palewire