So I'm working on a list view for one of my models and I want to display them by group like:

Group 1
  - Item
  - Item

Group 2
  - Item

 Group 3
  - Item
  - Item
  - Item

That's easy enough to do with regroup tag in Django, no problem there. But what if I want to paginate the queryset? Unless each group has the exact same number of items (they don't), I'll run into problems if I just do the standard:

queryset = Model.objects.all()
paginate_by = 10

So I'm wondering if there's anyway to paginate by group, or is Django's built in paginator totally incompatible with the regroup tag?

From my searching I get the feeling that I'd have to implement a custom pagination system to achieve this, but I couldn't find anything conclusive so thought I'd check here in case I'm missing something or possibly get some clean alternatives.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.