﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34640	Add query_params argument to test Client methods	Dan Strokirk	nobody	"Using `Client.get` it’s currently very easy to add new query parameters to the fake request, you can simply provide them to data argument. Very nice and ergonomic.

However, for the other HTTP methods, like post, this doesn’t work, since of course they use the same parameter for their form data. So adding a new argument to all methods would make it easier to test other HTTP methods. Since `request.GET` is getting renamed to `query_params`, that would be an excellent name for the new argument.

This would make it possible to change this type of testing code:

{{{
url = reverse(""view_name"", args=[obj.id]) + f""?param={val}""
self.client.post(url, data=data)
}}}

to this

{{{
url = reverse(""view_name"", args=[obj.id])
self.client.post(url, query_params={""param"": val""}, data=data)
}}}

`Client.get` would still support setting params via the `data` argument, to avoid unnecessary deprecation churn in old projects. Using both `data` and `query_params` together in `Client.get` would throw a `ValueError`.

Taken from: https://forum.djangoproject.com/t/suggestion-adding-params-to-testclient-http-methods/21246/1"	New feature	closed	Testing framework	dev	Normal	duplicate			Unreviewed	0	0	0	0	0	0
