From b1bf8c8a4ba04049dc19217bf0e876488a4fae3c Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 23 Sep 2021 12:18:15 +0200 Subject: Fixed #33132 -- Fixed test client handling of querystring only redirects. Regression in 1e5aa8e1c79252cc810af21294a6e945d11d37b3. --- django/test/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'django/test') diff --git a/django/test/client.py b/django/test/client.py index dd735dd833..c65e07ce7e 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -835,8 +835,11 @@ class Client(ClientMixin, RequestFactory): if url.port: extra['SERVER_PORT'] = str(url.port) + path = url.path + # RFC 2616: bare domains without path are treated as the root. + if not path and url.netloc: + path = '/' # Prepend the request path to handle relative path redirects - path = url.path or '/' if not path.startswith('/'): path = urljoin(response.request['PATH_INFO'], path) -- cgit v1.3