[Django] #36966: Test client using query_params raises ValueError when following redirect

4 views
Skip to first unread message

Django

unread,
Mar 4, 2026, 1:41:22 PM (3 days ago) Mar 4
to django-...@googlegroups.com
#36966: Test client using query_params raises ValueError when following redirect
-------------------------------------+-------------------------------------
Reporter: Marc | Owner: Marc Gibbons
Gibbons |
Type: Bug | Status: assigned
Component: Testing | Version: 6.0
framework |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When the test client is called with `query_params` and `follow=True`, a
`ValueError` is raised when following the redirect.

`_follow_redirect` populates `data` from the redirect URL's query string
via `QueryDict(url.query)`. Since `query_params` from the original request
is never reset, both `data` and `query_params` end up non-empty,
triggering: `ValueError: query_params and data arguments are mutually
exclusive.`

Ref:
https://github.com/django/django/blob/35dab0ad9ee2ed23101420cb0f253deda2818191/django/test/client.py#L998

== Reproduction ==

{{{
def test_follow_redirect_with_query_params(self):
self.client.get("/redirect_view/", query_params={"next": "x"},
follow=True) # this yells
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36966>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 4, 2026, 1:55:51 PM (3 days ago) Mar 4
to django-...@googlegroups.com
#36966: Test client using query_params raises ValueError when following redirect
-------------------------------------+-------------------------------------
Reporter: Marc Gibbons | Owner: Marc
| Gibbons
Type: Bug | Status: assigned
Component: Testing framework | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Marc Gibbons):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36966#comment:1>
Reply all
Reply to author
Forward
0 new messages