Opened 18 years ago
Closed 18 years ago
#4919 closed (fixed)
add ?page=last for generic object_list with pagination
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Generic views | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
usecase: you want to link to the last page, but you don´t know how many pages there are. e.g, when you have comments paginated and you want to link to the last comment posted, you could use ?page=last
except (InvalidPage, ValueError):
if page == 1 and allow_empty:
object_list = []
+ elif page == 'last':
+ page = paginator._get_pages()
+ object_list = paginator.get_page(page - 1)
else:
raise Http404
sorry, but submitting a patch didn´t work the last time, so I just put the code in here.
the above code-snippet is for django.views.generic.list_detail.object_list from line 52.
Attachments (1)
Change History (5)
comment:1 by , 18 years ago
| Has patch: | set |
|---|---|
| Needs documentation: | set |
| Patch needs improvement: | set |
| Triage Stage: | Unreviewed → Accepted |
by , 18 years ago
| Attachment: | lastpage.diff added |
|---|
Refactored patch plus generic views documentation
comment:2 by , 18 years ago
| Needs documentation: | unset |
|---|---|
| Patch needs improvement: | unset |
comment:3 by , 18 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:4 by , 18 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
This sounds like a good idea - but we'll need something in the docs about it. Can someone write up a patch that does Patrick's change, and adds a bit to the generic views docs?