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

Get data with query params #8951

Closed

Conversation

Mahmoud-Barry
Copy link

This commit adds the ability to filter the queryset based on query parameters included in the request URL. The list method now checks if the query parameters correspond to valid fields in the model, and filters the queryset accordingly. This improves the flexibility of the view and allows clients to retrieve a more specific subset of data.

@@ -39,6 +39,13 @@ class ListModelMixin:
def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())

try:
params = {key: value for key, value in request.query_params.items() if key in self.model._meta.get_fields()}
Copy link
Member

Choose a reason for hiding this comment

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

would you mind adding unit test to verify this change?

@auvipy auvipy closed this Apr 19, 2023
@auvipy auvipy reopened this Apr 19, 2023
@tomchristie
Copy link
Member

Thanks for you're interest.
We're not accepting functionality changes to this project other than bug fixes and Django-version-tracking changes.

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

3 participants