7

My url has http://127.0.0.1:8000/theme/category/?q=check,hello, How to retrive values of query parameter

When I try doing query = request.GET.get('q') I only get the check but hello is missing.

Any help in getting both check and hello from query string will be helpful

isherwood
  • 58,414
  • 16
  • 114
  • 157
Coeus
  • 2,385
  • 3
  • 17
  • 27
  • Does this answer your question? [How to handle request.GET with multiple variables for the same parameter in Django](https://stackoverflow.com/questions/3910165/how-to-handle-request-get-with-multiple-variables-for-the-same-parameter-in-djan) – mx0 Feb 12 '21 at 15:10

2 Answers2

14

For the URL http://example.com/blah/?myvar=123&myvar=567 you can use getlist() like this:

request.GET.getlist('myvar')
isherwood
  • 58,414
  • 16
  • 114
  • 157
Or Duan
  • 13,142
  • 6
  • 60
  • 65
1

You can use %2C, wich is the url-encoded value of ,.

source : Alternative to sending comma separated parameter by querystring

isherwood
  • 58,414
  • 16
  • 114
  • 157
Mohit Rustagi
  • 198
  • 1
  • 10