Login and Redirect

Posted by xRobot on Stack Overflow See other posts from Stack Overflow or by xRobot
Published on 2010-05-13T09:17:07Z Indexed on 2010/05/13 10:04 UTC
Read the original article Hit count: 336

Filed under:
|
|

This is my login views:

def login(request):

    redirect_to = request.REQUEST.get("next")
    if request.method == 'POST': 

        formL = LoginForm(data=request.POST)           
        if formL.is_valid(): 

            if not redirect_to or '//' in redirect_to or ' ' in redirect_to:
                redirect_to = "/blogs/"

            from django.contrib.auth import login
            login(request, formL.get_user())
            if request.session.test_cookie_worked():
                request.session.delete_test_cookie()
            return HttpResponseRedirect(redirect_to)

    else:

    formL = LoginForm(request)                 

request.session.set_test_cookie()  

return render_to_response('blogs.html', {
    'formL': formL, }, context_instance=RequestContext(request))

login = never_cache(login)

When I go, for example, to example.com/myblog/ then I have been redirect to example.com/accounts/login/?next=/myblog/

but when I insert user and psw for login then I have been redirect to /blogs/ and not /myblog/

Why ?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-forms