Django问题报错:TypeError: as_view() takes 1 positional argument but 2 were given

一、错误位置

from django.urls import path

from users_app.views import RegisterView, LoginView, LogoutView

app_name = 'users'
urlpatterns = [
    path("register/", RegisterView.as_view, name="register"),
    path("login/", LoginView.as_view, name="login"),
    path("logout/", LogoutView.as_view, name="logout"),
]

Django问题报错:TypeError: as_view() takes 1 positional argument but 2 were given_第1张图片

三、解决办法

as_view作为一个方法后面需要+()

    path("register/", RegisterView.as_view(), name="register"),
    path("login/", LoginView.as_view(), name="login"),
    path("logout/", LogoutView.as_view(), name="logout"),

你可能感兴趣的:(Django问题报错,django,数据库,sqlite)