Very simple:
1.Once you are in login page you need to store url to which you need
to go.
How should you do that?
protected view
===============
def protected_view(request) :
if user is not authenticated :
url = request.getpath() # method which actually
gives you the url of the protected page
#pass this url to the login page
render_to_response(...........,
{'url':url} .............}
login page.html
===============
<form .....................
<input type="hidden" name="next" value="{{url}} />
</form>
2.Once the login is successfull you need to retrieve the stored url
and redirect back to it.
login view.html
===============
def loginview(request) :
nexturl = request.POST['next']
#once the use is successfully loggedin
#redirect him to nexturl using httpresponseredirect
--rama
On Oct 12, 9:34 am, Bayuadji <[email protected]> wrote:
> On 10/11/09, Florian Schweikert <[email protected]> wrote:
>
>
>
> > 2009/10/12 Sergio A. <[email protected]>
>
> >> I've three views each with different URL. They are visible to logged
> >> in users.
> >> If a non-logged user tries to access a URL requiring login, I'm able
> >> to redirect it to the login page.
>
> >> What I'm missing is how to go back to the initial page, once the user
> >> log in the system.
>
> >> Cheers, Sergio
>
> > @login_required redirection using ?next=/path (I'm not 100% sure if this is
> > default)
> > your login have to look at this GET var
>
> > greets,
> > Florian
>
> Yes,
>
> I always use this kind mechanism though
>
> -djibon-
>
> --------------------------------------------------------------http://www.tumbletooth.org
> my linkedin profile :http://www.linkedin.com/in/bayuadji
> --------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---