Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #15742 -- Fixed an example of collecting selected objects in ModelAdmin.actions docs. #12016

Merged
merged 2 commits into from Nov 6, 2019

Conversation

danthedeckie
Copy link
Contributor

( https://docs.djangoproject.com/en/2.2/ref/contrib/admin/actions/#actions-that-provide-intermediate-pages )
/docs/ref/contrib/admin/actions.txt
in paragraph
Actions that provide intermediate pages

recommends directly accessing the form values:

selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)

to get a list of selected ids. This fails to take into account if the select all box has been selected.

This patch changes one line to suggest using the queryset to get the IDs, which results in the correct behaviour.

@danthedeckie danthedeckie force-pushed the docs-admin-actions-use-queryset branch from fb76f4f to d93e9b9 Compare November 4, 2019 11:54
@felixxm felixxm changed the title Refs #30951 -- Documentation - Use queryset rather than raw POST values for admin actions. Fixed #15742 -- Documentation - Use queryset rather than raw POST values for admin actions. Nov 6, 2019
@felixxm felixxm self-assigned this Nov 6, 2019
@felixxm felixxm force-pushed the docs-admin-actions-use-queryset branch from d93e9b9 to 9c14424 Compare November 6, 2019 11:46
@felixxm felixxm changed the title Fixed #15742 -- Documentation - Use queryset rather than raw POST values for admin actions. admin.ACTION_CHECKBOX_NAME Nov 6, 2019
@felixxm felixxm changed the title admin.ACTION_CHECKBOX_NAME Fixed #15742 -- Fixed an example of collecting selected objects in ModelAdmin.actions docs. Nov 6, 2019
@felixxm
Copy link
Member

felixxm commented Nov 6, 2019

@danthedeckie Thanks 👍 I removed unused import and pushed minor optimization to this example. I also added a separate commit to removed unused import in Django.

danthedeckie and others added 2 commits November 6, 2019 12:49
… in ModelAdmin.actions docs.

The queryset argument is already filtered, and request.POST doesn't
contain all selected objects when "Select All" is used.
@felixxm felixxm force-pushed the docs-admin-actions-use-queryset branch from 9c14424 to 4c45b62 Compare November 6, 2019 11:50
@felixxm felixxm merged commit 4c45b62 into django:master Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants