Skip to content

change testing client to take a list of tuples in the query params #274

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mercelino
Copy link

the function urlencode from urllib handles the case where in the input in query is a list of tuples, but it's not handled in django ninja extra

example:
client_test.get(f'/test', query=[('fields', 'field_name_1'), ('fields', 'field_name_2')]).json()

This will not work in the current version, but it would work if the isinstance(request_params["query"], dict) accepts a list as well

It's useful when passing a list of values for one query parameter.

@eadwinCode
Copy link
Owner

I think this can still work like this

client_test.get(f'/test', query={k:v for k, v in [('fields', 'field_name_1'), ('fields', 'field_name_2')]}).json()

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.

2 participants