The accepted answer didn’t work for me in django 1.6, so I ended up with this:
from django.contrib import admin
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
class MyModelAdmin(admin.ModelAdmin):
....
def changelist_view(self, request, extra_context=None):
if 'action' in request.POST and request.POST['action'] == 'your_action_here':
if not request.POST.getlist(ACTION_CHECKBOX_NAME):
post = request.POST.copy()
for u in MyModel.objects.all():
post.update({ACTION_CHECKBOX_NAME: str(u.id)})
request._set_post(post)
return super(MyModelAdmin, self).changelist_view(request, extra_context)
When my_action is called and nothing is selected, select all MyModel instances in db.