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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With