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
--
Ticket URL: <https://code.djangoproject.com/ticket/34640>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #14611.
--
Ticket URL: <https://code.djangoproject.com/ticket/34640#comment:1>