I have this url = http://stackoverflow.com/questions/ask?next=1&value=3
Now I need to get the query string from this url.
I don;t wanna use request.META for getting query string. How ever I figured it out that there are two more ways to get the query string
Using urlparse
Use urlparse.urlparse(url).query dats it
Using url encode
Use urlencode and pass the request.GET params dictionary into it,to get the string representation of it....
So which way is better to get the query string...?
Some of my colleagues are saying that urlencode is much better , however I am not satisfied wid there answers so far..like they mentioned urlparse calls urlencode internally too..Even on this point I have doubt as I think urlparse and urlencode are entirely independent.as urlencode is in urllib module....please clarify this thing.
解决方案
You can make Query string using GET parameters like this
request.GET.urlencode()