-
-
Notifications
You must be signed in to change notification settings - Fork 819
Description
Describe the bug
When using the export functionality through admin actions (selecting multiple records and exporting), the export process loses all applied admin filters. This results in exports containing records that don't match the filtered changelist view, leading to data inconsistency and incorrect exports.
To Reproduce
Steps to reproduce the behavior:
- Go to any Django admin changelist that uses ExportActionMixin
- Apply filters to narrow down the results
- Select multiple records from the filtered results using checkboxes
- Choose "Export selected [model]" from the action dropdown
- See that the export form appears but the exported data ignores all applied filters
- Result: Export contains records that don't match the filtered view
Versions (please complete the following information):
- Django Import Export: 4.0.0+ (issue introduced in v4.0.0)
- Python 3.8+
- Django 4.2+
Expected behavior
Exports should respect all applied admin filters and only export records that match the current filtered view, maintaining consistency between what users see in the changelist and what gets exported. This was the behavior in django-import-export versions prior to v4.0.0.
Additional context
The export form URL ("export_url" in the context) doesn't include the query parameters necessary for the export queryset to correctly narrow down the results. When the export form is submitted, it lacks the filter context (like ?date=2024-01-01&status=active) that was present in the original changelist view, causing the export to process the unfiltered dataset.