Opened 9 years ago

Last modified 6 years ago

#15742 new Bug

Bug: Mark all does not contain full queryset when using intermidiate pages in Django admin

Reported by: Herman S <herman.schistad@…> Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Let's say you implement some intermidiate page for your actions in django admin, as described in the docs here:

When you call the {{ queryset }} in the intermediate page, it is all good. But let's say you have a "confirm this action" page, and when you actually call the queryset again - then the problem occurs.
It only happens when you choose more than the 100 objects on the first page and select all object with the "select all" javascript button. The action is only applied to the objects on the first page.

In order to replicate this bug:

  1. Create 100++ objects of some type
  2. Create an intermediate page which is called at some action.
  3. Choose ALL objects with first pressing the top selectbox, now the "choose all" button should appear and press this. Apply the action.
  4. Confirm it at the intermediate page.
  5. Observe that the action is only applied to the objects at the first page.

I found this article to explain the admin intermediate page actions very good:

Change History (6)

comment:1 Changed 9 years ago by Karen Tracey

Component: contrib.adminDocumentation
Triage Stage: UnreviewedAccepted

The problem here involves how the "queryset" is preserved from the original action handler to the code that handles POST for the intermediate page. In the referenced blog post this is done like so:

if not form:
    form = self.AddTagForm(initial={'_selected_action': request.POST.getlist(admin.ACTION_CHECKBOX_NAME)})

This code is not actually using the queryset parameter passed into the action function but rather the list of selected action checkboxes in the post data, which is only going to be the 100 checkboxes on the individual page. The action code should be using the passed queryset parameter, which does contain the full list of all items, rather than this post data. However Django's doc at the moment shows exactly this technique of using the POST data, and that should be fixed.

As noted in the referenced blog post, the doc here is a bit lacking and in general would benefit from more complete examples. Besides not working correctly for the "select all" case, the current example of stuffing all the pks into a querystring doesn't extend well to potentially thousands of items selected -- you're going to run into querystring length issues I think. at some point. It would be good if the doc here considered some workable techniques for handling the case of thousands of selected items.

comment:2 Changed 8 years ago by Karen Tracey

Easy pickings: unset

#16081 reported this again.

comment:3 Changed 8 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:4 Changed 7 years ago by anonymous

I found similar problem.

In admin class of some object I set list_editable attribute. Open change-list page. Make some changes. If in site's users-side some object was added between you open admin change-list page and click save button, last objects of current page in admin page will not correctly save.

I solved this problem removing
in django/contrib/admin/ at 1184 line

comment:5 Changed 6 years ago by gamesbook@…

Any chance this will be fixed for 1.6 ... intermediate pages are really useful and this limits their applicability!

comment:6 Changed 6 years ago by Derek Hohls

Can anyone look at the Django source code and figure a fix, based on the discussions hosted at ?

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