0

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.