tags:

views:

107

answers:

1

In my django view, i have logic that retrieves a querystring variable called url from the request object like so:

link: http://mywebsite.com/add?url=http://www.youtube.com/watch?v=YSUn6-brngg&description=autotune-the-news

url = request.Get.get("url")

The problem arises, for example,when the url variable itself contains parameters(or variables)

link:http://mywebsite.com/add?url=http://www.youtube.com/watch?v=YSUn6-brngg&feature=SeriesPlayList&description=autotune-the-news

The feature parameter will be treated as a seperate variable. Since i don't always know the parameters that would be included inside the url variable, how can i force it to retrieve everything that comes before the description variable?

+2  A: 

This is a URL encoding problem. Whatever technology is being used to generate the request needs to URL-encode the value for the 'url' parameter. This will make your link look like:

http://mywebsite.com/add?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYSUn6-brngg%26feature%3DSeriesPlayList&description=autotune-the-news

Now, Django will be able to parse the 'url' parameter completely without getting confused about the 'feature' and 'description' parameters. So, all you have to do is figure out how to get the UI technology used to create the link to encode that parameter.

saleemshafi