Rob Hudson schreef:
IIRC, that gets set based on what is in the login form's hidden field
named "next". REDIRECT_FIELD_NAME is in django.contrib.auth and is set
to "next" by default.
You can override it in the template like this:
<input type="hidden" name="next" value="/">
This will always redirect to the root of the site "/".
If that value is empty, it will default to /accounts/profile/ after
login. So make sure to set it.
I've actually done this in my login template:
<input type="hidden" name="next" value="{% if next %}{{ next }}{%
else %}/{% endif %}">
This uses the next value if it exists -- when the login_required
decorator takes over and makes the user login, it sets the next
variable to where the user tried to go. But if it doesn't exist, I
force it so Django doesn't default to /accounts/profile/.
-Rob
Hi Rob,
i tried specifying setting a hidden field next to "/" and a link to
somewhere on the site and it didn't work.
This is probably because i switched to using this code
if not request.user.is_authenticated():
return HttpResponseRedirect("/login/")
to do authentication instead of using @login_required as login_required
redirects to accounts/login/. With login_required, i see that it indeed
sets next automatically.
How would one set next from a view with the code i showed above?
How can i have login_required link to another page than accounts/login?
Thanks,
Benedict
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---