Luis Rodriguez
Luis Rodriguez

Reputation: 277

Capture ALL query parameters in GET request

I have a GET request with an endpoint looking like this:

http://127.0.0.1:8000/api/tweets/alldata/?0=1&1=2

I know I can reach individual values with the key, but how do I capture ALL values in one variable?

I've tried it like this but nothing is captured at all:

followers = self.request.query_params.get('')

Upvotes: 0

Views: 115

Answers (1)

Iain Shelvington
Iain Shelvington

Reputation: 32244

self.request.GET

Is a dictionary-like object that contains all query parameters

It is immutable (can't be edited) but you can create a copy if you need a mutable object:

data = self.request.GET.copy()

Upvotes: 1

Related Questions