Opened 4 years ago

Closed 4 years ago

#22529 closed New feature (needsinfo)

Paginator: Get page number using object unique attributes

Reported by: kasturisurya@… Owned by: nobody
Component: Core (Other) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Lets consider the situation:

obj_list = MyModel.objects.filter(is_displayed=True)
pages = Paginator(obj_list, 1)

current_page = pages.page(self.pk)

If for instance obj_list does not contain all objects, the page number of self.pk will not be the value of self.pk in which case the paginator raises Empty Page exception.

This can be quite elegantly handled if page method can do or something similar to below

current_page = pages.page(pk=self.pk)

Change History (1)

comment:1 Changed 4 years ago by Tim Graham

Resolution: needsinfo
Status: newclosed

Sorry, I'm having trouble understanding this suggestion. Could you provide some more details or a patch that demonstrates the changes you are proposing?

Note: See TracTickets for help on using tickets.
Back to Top