2013-12-08 20 views
1

我在嘗試使用「登錄()」Django的登錄需要1個參數,而不是2

login() takes exactly 1 argument (2 given) 

現在我用這個來處理我的用戶登陸和IM此錯誤時非常肯定它的工作我抄之前它。壽現在它告訴我,我給2個參數,除了1

我登錄視圖:

def login(request): 
    """Logs a user into the application.""" 

    auth_form = AuthenticationForm(None, request.POST or None) 
    # The form itself handles authentication and checking to make sure passowrd and such are supplied. 
    if auth_form.is_valid(): 
     login(request, auth_form.get_user()) 
     return HttpResponseRedirect(reverse('index')) 

    return render(request, 'login.html', {'auth_form': auth_form}) 

不要有任何想法什麼即時通訊做錯了。

回答

2

您使用相同名稱login作爲視圖名稱;這會影響你想要調用的功能。

對視圖使用不同的名稱。

或致電login功能與合格的形式:

django.contrib.auth.login(request, auth_form.get_user()) 
+0

由於完全忘了這一點,一直坐在了一段時間:) –

相關問題