Opened 16 years ago

Closed 15 years ago

#9798 closed (wontfix)

object_list paginated raise a http404 when a its a InvalidPage

Reported by: zodman Owned by: nobody
Component: Generic views Version: dev
Severity: Keywords: page paginator object_list
Cc: askfor@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

on views.generic.list_details.object_list

        if not page:
            page = request.GET.get('page', 1)
        try:
            page_number = int(page)
        except ValueError:
            if page == 'last':
                page_number = paginator.num_pages
            else:
                # Page is not 'last', nor can it be converted to an int.
                raise Http404
        try:
            page_obj = paginator.page(page_number)
        except InvalidPage:
            raise Http404

Let me check this case when i have a page with this url

foo/bar/?page=10

on page ten i have 3 objects showed.

if i delete 3 objects the page its invalid not a Http404, because the page exist before erase ...

its better do the same validator a example on paginator, if the page not exist get the latest page/objects.

Change History (3)

comment:1 by Jacob, 16 years ago

Resolution: wontfix
Status: newclosed

This is an intentional behavior, not a bug. A missing page is a 404.

comment:2 by askfor, 15 years ago

Cc: askfor@… added
Resolution: wontfix
Status: closedreopened

I came across the same problem.
User delete some objects and then redirect to the previous page, got a http404.
It would be better if we can control the behavior. (get the last page as zodman said or something else)
And all those date-based generic views have the "allow_empty" argument so that this behavior can be controlled by programmer.

comment:3 by Alex Gaynor, 15 years ago

Resolution: wontfix
Status: reopenedclosed

You can control the behavior. Write your own wrapper function. In any event if you disagree the closure of a ticket by a core developer please do not reopen it, instead start a discussion on the django-developers mailng list.

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