本文主要是介绍Django问题报错:TypeError: as_view() takes 1 positional argument but 2 were given,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、错误位置
from django.urls import pathfrom users_app.views import RegisterView, LoginView, LogoutViewapp_name = 'users'
urlpatterns = [path("register/", RegisterView.as_view, name="register"),path("login/", LoginView.as_view, name="login"),path("logout/", LogoutView.as_view, name="logout"),
]
三、解决办法
as_view作为一个方法后面需要+()
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的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!