django create user and log them in

Posted by Scott Willman on Stack Overflow See other posts from Stack Overflow or by Scott Willman
Published on 2010-04-18T05:31:16Z Indexed on 2010/04/18 5:33 UTC
Read the original article Hit count: 464

Filed under:
|

In a view I'm trying to create a new user and then log them in but result in a new url on success.

def create(request):

    if request.method == "POST":

        # do user creation #
        user.save()

        auth_user = authenticate(username=user.username,password=user.password)

        if auth_user is not None:
            login(request, auth_user)

            return HttpResponseRedirect('/user/account/')

    return render_to_response('create_form.html')

So, how do I maintain the user object using the HttpResponseRedirect or validate the logged in user in an unassociated view?

© Stack Overflow or respective owner

Related posts about user

Related posts about authenticate