Question

Sometimes in my code I pass get parameters with URL's. One particular scenario is if the user is not logged in, but puts a URL for a page that requires login, they will be required to login first.

In that case I may have a URL such as: www.example.com/home/#/main/.

The end of the URL /#/main/ is for angular. However, in django when I do the below to get the next parameter above, I do this:

self.request.GET.get('next', self.redirect_url)

The problem is that in this case, next provides everything but the angular portion, so I get: www.example.com/home/.

Is there anyway to get the remaining portion of the URL as well?

Was it helpful?

Solution

You have to urlencode the url before you add it as a parameter. Then it will turn into %23 and insn't the separator for the anchor anymore, which is handled client side only as KVISH described.

OTHER TIPS

Apparantly you can't. Django doesn't even see the anchor, its all handled on client (browser).

How to identify an anchor in a url in Django?

The way I got around this is I use jQuery to set a hidden input field to the hash location, which can be obtained like so:

window.location.hash

The hash gets submitted with the form and I can take it from there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top