Django TypeError:logout()至少需要1个参数(给定1个)

时间:2016-12-02 18:28:28

标签: django django-authentication

我不明白为什么这个网址会给我一个错误:

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()至少需要1个参数(给定1个)

1 个答案:

答案 0 :(得分:4)

您直接在网址定义中调用注销视图。

如果需要传递参数,则应在单独的字典中执行:

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