2016-12-02 85 views
1

我不明白爲什麼這個網址是給我的錯誤:Django的類型錯誤:註銷()至少需要1個參數(1給出)

from django.contrib.auth import views as auth_views 
from django.core.urlresolvers import reverse_lazy 

... 
url(r'^logout/$', auth_views.logout(next_page=reverse_lazy("dashboard:operations_login")), name="operations_logout"), 
... 

的錯誤是:

Django TypeError: logout() takes at least 1 argument (1 given)

回答

4

你直接在你的url定義中調用註銷視圖。

如果需要傳遞參數,你應該在一個單獨的字典這樣做:

url(r'^logout/$', 
    auth_views.logout, 
    {'next_page': reverse_lazy("dashboard:operations_login")}, 
    name="operations_logout"), 
相關問題