django manual login and redirect
Posted
by Zayatzz
on Stack Overflow
See other posts from Stack Overflow
or by Zayatzz
Published on 2010-04-02T13:09:34Z
Indexed on
2010/04/02
13:13 UTC
Read the original article
Hit count: 392
Hello
I have such view that handles user registration. After creating new user i want to manually authenticate it and log it in.:
def register(request):
...
...
if form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
email = ''
newuser = User.objects.create_user(username, email, password)
user = authenticate(username=username, password=password)
login (request, user)
I have set LOGIN_REDIRECT_URL to '/profile/', but after authenticating and logging user in, it redirects me back to the same view not to /profile/, why? And how can i specify where to redirect after logging in? If i add
HttpResponseRedirect('/profile/')
After login line - nothing happens. The script never ends up there.
Alan.
© Stack Overflow or respective owner