Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to ONLY export what I want? #1452

Closed
monalisir opened this issue Jun 23, 2022 · 7 comments
Closed

how to ONLY export what I want? #1452

monalisir opened this issue Jun 23, 2022 · 7 comments
Labels

Comments

@monalisir
Copy link

Thanks for this app.
I'm using it to export data from django admin.
But I face a problem, how to ONLY export the data after filtering.
Just like there are 30000 records in the DB table, after filtering, I get 200 records. How to ONLY export these 200 records?
I do not want to export them all.

Thank you.

@pokken-magic
Copy link

pokken-magic commented Jun 23, 2022

Iirc export can accept a queryset.

There’s no great way to do that in admin I am aware of but you can write a management command to run resource.export(queryset) basically. Make an instance of the resource and run export with the queryset as an arg. Can also be done via shell if it’s ad hoc.

There may be a way I am not thinking of too. You could certainly enhance the admin templates to let you specify a range of ids or something if it needed to be in a ui

@matthewhegarty
Copy link
Contributor

I had a look at the API and concluded that it wasn't straightforward to override and specify filters for an export. This could be a useful addition.

@merwok
Copy link

merwok commented Jul 17, 2022

Isn’t that what ExportActionModelAdmin (and subclasses) are for? They let you use admin filters, date filters, search and manual check/uncheck of rows to select, then choose the export action from bulk actions menu and export the selection.

@Yodale1000
Copy link

Isn’t that what ExportActionModelAdmin (and subclasses) are for? They let you use admin filters, date filters, search and manual check/uncheck of rows to select, then choose the export action from bulk actions menu and export the selection.

How do i implement it that way ?

@merwok
Copy link

merwok commented Jul 22, 2022

See https://django-import-export.readthedocs.io/en/stable/getting_started.html#exporting-via-admin-action

@matthewhegarty
Copy link
Contributor

#1477 related question

@matthewhegarty
Copy link
Contributor

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants