views:

346

answers:

1

Hi all, In Python and GAE, I would like to ask how to get the parameters of a query string in the url. As I know, the query_string part returns all the part after the "?" in the url. So what I have to do is to split the query string with "&", and use the variables. Is there any other convinient way to manage the query string? How do you normally do it?

str_query = self.request.query_string
m = str_query.split('&')
a = m[0] 
b = m[1]
c = m[2]

Doing this way, in case, the query_string does not have any values, it threw an error:

IndexError: list index out of range
+8  A: 

You don't need to complicate. You can retrieve all GET parameters with:

self.request.get('var_name')

Or if you want to retrieve them all in one list you can use:

self.request.get_all()

You can find more info on the Request class here.

rogeriopvl
Thank you rogerio, it works!
sfa