문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top