Reputation: 1087
I have several possible parameter to process in a page. Assume x0, x1, x2,..., x1000. It seems awkward to get and process them one by one by request.GET.get('x0'), request.GET.get('x1'), ...
Any idea to put them in a list, so that they can be processed in a loop.
Upvotes: 1
Views: 29
Reputation: 21734
Since, request.GET
is a dictionary, you can access its values like this:
for var in request.GET:
value = request.GET[var]
# do something with the value ...
Or if you want to put the values in a list:
val_list = []
for var in request.GET:
var_list.append(request.GET[var])
Upvotes: 3