Question

I'm using this snippet to export 'selected' data to csv. It's working well. Is there any way to make this work without selecting them? So it would just export the entire model by default?

Was it helpful?

Solution

Sure, ignore queryset in the snippet and replace it with MyModel.objects.all() to give it all objects, always.

You're still going to have to select an item to run an action though, as the admin actions must have an item selected to run.

This question comes up pretty often - you can roll your own system that works without selecting an item (like overriding an admin template with a button, then setting up a view to resopnd to the button by exporting the CSV) but this is the easiest solution.

OTHER TIPS

You can replace queryset by modeladmin.model.objects.all()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top