Given a URL like the following, how can I parse the value of the query parameters? For example, in this case I want the value of def
.
/abc?def='ghi'
I am using Django in my environment; is there a method on the request
object that could help me?
I tried using self.request.get('def')
but it is not returning the value ghi
as I had hoped.
There's not need to do any of that. Only with
Notice that I'm not specifying the method (GET, POST, etc). This is well documented and this is an example
The fact that you use Django templates doesn't mean the handler is processed by Django as well
I'm shocked this solution isn't on here already. Use:
This will "get" the variable from the "GET" dictionary, and return the 'variable_name' value if it exists, or a None object if it doesn't exist.
for Python > 3.4
The url you are referring is a query type and I see that the request object supports a method called arguments to get the query arguments. You may also want try
self.request.get('def')
directly to get your value from the object..In pure Python: