#15742 closed Cleanup/optimization (fixed)
Bug: Mark all does not contain full queryset when using intermidiate pages in Django admin
Reported by: | Owned by: | Daniel | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | 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
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:
- Create 100++ objects of some type
- Create an intermediate page which is called at some action.
- Choose ALL objects with first pressing the top selectbox, now the "choose all" button should appear and press this. Apply the action.
- Confirm it at the intermediate page.
- 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/
Change History (11)
comment:1 by , 14 years ago
Component: | contrib.admin → Documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 12 years ago
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 by , 11 years ago
Any chance this will be fixed for 1.6 ... intermediate pages are really useful and this limits their applicability!
comment:6 by , 11 years ago
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/ ?
comment:7 by , 5 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Type: | Bug → Cleanup/optimization |
Version: | 1.3 → master |
comment:8 by , 5 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
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:
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 passedqueryset
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.