Thanks Malcolm, That was very informative. I tried the percent encoding trick with no success. Now I'll try the second part and post here if I am successful.
Thanks, Bastien On Apr 29, 6:50 pm, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Wed, 2009-04-29 at 07:43 -0700, Bastien wrote: > > Hi, > > > I'm trying to get Django to do the following: > > > A user must be logged in to comment on a content. If the user is not > > logged in then I provide a link to the login page and use the 'next' > > function to take her back to the content page where the comment box > > will be waiting for her to fill it. > > > It almost works, the only thing is that the comment box can be quite > > far away down the page if there are lots of comments and I would like > > to go to it directly adding a '#comment_form' at the end the 'next' > > url. That's what I do, I call a url that looks like this: > >http://mysite.com/accounts/login/?next=/content/#comment_formbut the > > url returned by the login is a stripped down version that doesn't > > contain the trailing part with the '#comment_form'. > > You need to do some URL encoding here and/or possibly something extra in > the view. The anchor portion of the URL (the part following the "#") is > not sent to the server when the URL is submitted. This is arguably > somewhat of a flaw in the way HTTP URI's are interpreted by browsers, > but that's the way things work, so we have to work with it. You can send > URLs containing anchor elements from the server to the browser, but > browsers won't send the anchor to the server. > > As a first step, try percent-encoding the "#" (%23). That might then > work out of the box. If it doesn't, the next step would be to add a > wrapper around the login view and convert the URL you submit to the URL > you want to redirect to before calling the real login() view and passing > in the true target URL. > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---