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

Make queryset more consistent for ViewSets #103

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
History
=======

Unreleased
------------------

* Make querysets more consistent for ViewSets

1.4.0 (2025-01-28)
------------------

Expand Down
3 changes: 3 additions & 0 deletions import_export_extensions/api/views/export_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class ExportJobViewSet(

def get_queryset(self):
"""Filter export jobs by resource used in viewset."""
if self.action == getattr(self, "export_action", ""):
# To make it consistent and for better support of drf-spectacular
return super().get_queryset() # pragma: no cover
return super().get_queryset().filter(
resource_path=self.resource_class.class_path,
)
Expand Down
3 changes: 3 additions & 0 deletions import_export_extensions/api/views/import_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class ImportJobViewSet(

def get_queryset(self):
"""Filter import jobs by resource used in viewset."""
if self.action == getattr(self, "import_action", ""):
# To make it consistent and for better support of drf-spectacular
return super().get_queryset() # pragma: no cover
return super().get_queryset().filter(
resource_path=self.resource_class.class_path,
)
Expand Down