当前位置:   article > 正文

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

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

一、错误位置

  1. from django.urls import path
  2. from users_app.views import RegisterView, LoginView, LogoutView
  3. app_name = 'users'
  4. urlpatterns = [
  5. path("register/", RegisterView.as_view, name="register"),
  6. path("login/", LoginView.as_view, name="login"),
  7. path("logout/", LogoutView.as_view, name="logout"),
  8. ]

三、解决办法

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/80604
推荐阅读
相关标签
  

闽ICP备14008679号