Opened 5 years ago

Closed 5 years ago

#31188 closed Bug (wontfix)

Query param values got converted to lists.

Reported by: Davit Tovmasyan Owned by: nobody
Component: HTTP handling Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Steps to reproduce:

  1. Create a simple view
class SomeView(View):
    def get(self, request, *args, **kwargs):
        ...
        print(request.GET)
        ...
  1. Create URL pattern for the view as usual
...
path('some/', SomeView.as_view()),
...
  1. Do a GET request with query param using Client from django.test
...
c = Client()
c.get('some/', {'param': 1})
...

Remember this print(request.GET) code in CBV ?
The value is <QueryDict: {'param': ['1']}> and not <QueryDict: {'param': '1'}> as expected.

The same output when doing this way

...
c = Client()
c.get('some/?param=1')
...

Change History (1)

comment:1 by Mariusz Felisiak, 5 years ago

Component: Testing frameworkHTTP handling
Resolution: wontfix
Status: newclosed
Summary: Query param values got converted to lists when using Client from django.testQuery param values got converted to lists.

This is an expected and documented behavior.

Note: See TracTickets for help on using tickets.
Back to Top