首页 新闻 赞助 找找看

django 捕获异常出错

0
悬赏园豆:10 [已解决问题] 解决于 2016-03-02 08:53
def do_login(request):
    try:
        if request.method == 'POST':
            backform = BackForm(request.POST)
            if backform.is_valid():
                username = backform.cleaned_data['email']
                password = backform.cleaned_data['password']
                user = authenticate(email=username,password=password)
                print user
                if user:
                    user.backend = 'users.auth.customBackend'# 指定自定义的登录验证方式
                    auth_login(request, user)
                    return render(request,'common/index.html',locals())
                else:
                    return render(request,'common/error.html',{'error':'user is None'})
            else:
                render(request,'common/error.html',{'error':'backform is not valid'})
        else:
            render(request,'common/error.html',{'error':'request.method is not POST'})
    except Exception as e:
        logger.error(e)
    return render(request,'common/error.html',{'error':'e'})

居然返回了最后一段代码

return render(request,'common/error.html',{'error':'e'})

不应该啊

请问哪里出错了?

意发并行的主页 意发并行 | 初学一级 | 园豆:3
提问于:2016-03-01 14:50
< >
分享
最佳答案
0

确实在返回了error.html页面,只不过是没跳转而已,需要用pdb进行调试

意发并行 | 初学一级 |园豆:3 | 2016-03-02 08:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册