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

Minor refactoring to support filtering exports #1579

Conversation

matthewhegarty
Copy link
Contributor

@matthewhegarty matthewhegarty commented Apr 26, 2023

Problem

#1578
It is not possible to modify the Admin UI to include a custom field for export. This is possible for import but not export.

The bug is due to the fact that the form is removed from kwargs hence cannot be used in custom Resources to filter the queryset.

Solution

  • changed the pop() call so that the form remains in kwargs
  • Added a new filter_export() hook to make it a lot easier to dynamically filter querysets for export
  • Updated the example app to demonstrate using 'E Book'

Acceptance Criteria

  • Ran integration tests
  • Manual testing
  • Updated Documentation

Other refactoring

  • Split the test fixtures into 'book', 'categories' and 'author'
  • Split import / export tests in test_admin_integration.py for better readability

@coveralls
Copy link

coveralls commented Apr 26, 2023

Coverage Status

Coverage: 100.0%. Remained the same when pulling fb6282f on matthewhegarty:issue-1578-filtering-export-from-form into 0ff664c on django-import-export:main.

@matthewhegarty matthewhegarty marked this pull request as ready for review April 26, 2023 14:13
Copy link

@pokken-magic pokken-magic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a useful tool. The general trend toward increasing granularity of operations makes sense to me and is something we will probably keep doing elsewhere.

@matthewhegarty matthewhegarty merged commit a5dda8a into django-import-export:main Apr 26, 2023
13 checks passed
@matthewhegarty matthewhegarty deleted the issue-1578-filtering-export-from-form branch April 26, 2023 15:36
@youtux
Copy link

youtux commented Sep 14, 2023

Hi, can you please make a release with this fix? I can't customize the export form without this.

@matthewhegarty
Copy link
Contributor Author

yes, my plan is to release it this week

@matthewhegarty
Copy link
Contributor Author

Latest release (3.3.0) now available https://pypi.org/project/django-import-export/

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

Successfully merging this pull request may close these issues.

None yet

4 participants