{{{
>>> request_factory = AsyncRequestFactory()
>>> request = request_factory.get('/somewhere/', {'var': '100'})
>>> request.GET
<QueryDict: {}>
}}}
while in synchronous
{{{
>>> request_factory = RequestFactory()
>>> request = request_factory.get('/somewhere/', {'var': '100'})
>>> request.GET
<QueryDict: {'var': ['100']}>
}}}
This also prevents AsyncClient.get() from passing GET parameters to view
function.
--
Ticket URL: <https://code.djangoproject.com/ticket/32929>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* version: 3.2 => dev
--
Ticket URL: <https://code.djangoproject.com/ticket/32929#comment:1>
* cc: Andrew Godwin, Carlton Gibson (added)
* stage: Unreviewed => Accepted
Comment:
Thanks for the report, good catch. I think the following should do the
trick:
{{{
diff --git a/django/test/client.py b/django/test/client.py
index 4a0b6b45f4..b4c091aa5c 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -547,6 +547,8 @@ class AsyncRequestFactory(RequestFactory):
follow = extra.pop('follow', None)
if follow is not None:
s['follow'] = follow
+ if query_string := extra.pop('QUERY_STRING', None):
+ s['query_string'] = query_string
s['headers'] += [
(key.lower().encode('ascii'), value.encode('latin1'))
for key, value in extra.items()
}}}
Would you like to prepare a patch? (tests are also required).
--
Ticket URL: <https://code.djangoproject.com/ticket/32929#comment:2>
* has_patch: 0 => 1
Comment:
Replying to [comment:2 Mariusz Felisiak]:
> Would you like to prepare a patch? (tests are also required).
Yes, I have submitted a pull request.
https://github.com/django/django/pull/14639
--
Ticket URL: <https://code.djangoproject.com/ticket/32929#comment:3>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32929#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f6d3557aa13f33cfe2fa41094fc3d8a8b09c368c" f6d3557a]:
{{{
#!CommitTicketReference repository=""
revision="f6d3557aa13f33cfe2fa41094fc3d8a8b09c368c"
Fixed #32929 -- Fixed handling query strings in AsyncRequestFactory.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32929#comment:5>