How to get all GET request values in Django?

django, get, python, python-3.x, url-parameters

Solution

The second parameter is `5`, so you access `'Happy birthday'`:

request.GET.get('5', '')

note that the strings here will contain the single quotes (`'…'`) as content of the string. So normally this should be done without quotes.

You can get a list of key-value pairs with:

>>> dict(request.GET)
{'1': ["'12-18'"], '5': ["'Happy birthday'"]}

This will use the keys as keys of the dictionary, and maps to a list of values, since a single key can occurs multiple times in the querystring, and thus map to multiple values.

Problem

How can I get all of those url parameters (1, 12-18, 5,Happy birthday) in Django? ``` https://domain/method/?1='12-18'&5='Happy birthday' ``` I have tried: ``` parameter = request.GET.get("1", "") ``` But I only get 12-18.

Original source

Related problems