"Select all" not working for admin actions

Hi all - Django 2.2 user here (2.2.13), trying to make an admin action that can be invoked on all objects in the queryset (not just one page). I’m having some unexpected behavior with the “Select all” hyperlink in the Admin Actions section of my admin pages:


When I click the link, it makes it seem that all rows in the queryset have been selected - it says “All 301 selected”, with a Clear Selection link. But when I select an action (the built-in Delete Selected one) and press “GO”, I get back a pop-up claiming nothing was selected, and the action fails.

This seems to be a problem in Django 3 as well - the code currently in master early-exits if no checkboxes on the left of the page were marked, regardless of whether select_across is in the request (i.e. “Select all” was clicked). It’s not just me having this problem - people have posted and maintained workarounds since 2017, but they’re a bit hacky and sometimes cause other issues.

This early-exit error notwithstanding, I can get around the “none selected” popup by clicking the checkbox at the top of the page to select all 100 rows on the page, then clicking the “Select all” link to presumably expand it out to all 301. However, when I press “Go”, only the 100 that were on the page get included in the action.

It’s not just an “action with an intermediate page” problem - I tried the same thing with my own custom admin action for exporting to CSV, and I get the exact same behavior: it disregards my having clicked Select All, and only includes what was indicated with the checkboxes on the left in the action.

And on top of all of this, when I start clicking individual checkboxes, the “Select all” link goes away, and I have to reload the page to bring it back as an option.

Anyone else having problems like this, or have ideas for how to fix it?

Adding to this in case anyone else comes across it:

I had the same issue, the problem was with my overridden actions.html template.

The tags for “all”, “question”, and “clear” need to be hidden on page load. The “click” action on the select all checkbox in the top right (id=action-toggle) will show the other select all controls.

See django/actions.html at main · django/django · GitHub