功能不返回任何东西

时间:2016-07-08 04:30:18

标签: python django

我的观点

def login(request):
    c = {}
    c.update(csrf(request))
    return render_to_response(request,
'login.html', c)

def auth_view(request):
    username = request.POST.get
('username', '')
    password = request.POST.get
('password', '')
    user = auth.authenticate
(username = username, password =
password)
    if user is not None:
       auth.login(request,user)
        if request.method == 'POST':
            return HttpResponseRedirect('accounts/loggedin/')
        else:
             Retun HttpResponseRedirect('accounts/invalid/') 

函数auth_view没有返回任何内容时出错。

1 个答案:

答案 0 :(得分:1)

如果userNone,则auth_view不会返回任何内容。你必须返回一个HttpResponse ......