Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top