add ?page=last for generic object_list with pagination
|Reported by:||Owned by:||nobody|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.
Change History (5)
comment:1 Changed 10 years ago by
|Patch needs improvement:||set|
|Triage Stage:||Unreviewed → Accepted|