Saturday, May 28, 2011

Re: @login_required & Redirect...best practice?

When I have a view that's @login_required -- and the user isn't logged
in -- what's the best way to deal with the URL they wanted in the
first place? Assuming they log in properly and I want to then
redirect them on to where they intended to go in the first
place...what's the best practice?
@login_required will redirect to your login page a site the "next" param e.g.  /accounts/login?next=/where/you/where

The base url for that login page can be set in settings.py  as LOGIN_URL


From the login page you will want to set "next" param in post form used for login (or use the built in form in the auth module)


Mick

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment