Code

Opened 3 years ago

Last modified 7 months 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

Description

Let's say you implement some intermidiate page for your actions in django admin, as described in the docs here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#actions-that-provide-intermediate-pages

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: http://www.jpichon.net/blog/2010/08/django-admin-actions-and-intermediate-pages/

Attachments (0)

Change History (6)

comment:1 Changed 3 years ago by kmtracey

  • Component changed from contrib.admin to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 3 years ago by kmtracey

  • Easy pickings unset

#16081 reported this again.

comment:3 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:4 Changed 18 months 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
queryset=cl.result_list
in django/contrib/admin/options.py at 1184 line

comment:5 Changed 11 months 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 7 months ago by gamesbook

Can anyone look at the Django source code and figure a fix, based on the discussions hosted at http://www.jpichon.net/blog/2010/08/django-admin-actions-and-intermediate-pages/ ?

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.