AttributeError: module 'django.contrib.auth.views' has no attribute 'login'

前端 未结 2 1645
执念已碎
执念已碎 2020-12-21 00:54

I got error on my django rest framework, I am running it on windows 10 OS. this is the entire error:

Traceback (most recent call last):
  File \"manage.py\",         


        
2条回答
  •  别那么骄傲
    2020-12-21 01:09

    You currently define the login URL as:

    url(r'^login/$', views.login, template_name, name='login'),
    

    In Django 2.1, this deprecated functionality was removed.

    To fix the issue, you can change the line to:

    url(r'^login/$', views.LoginView.as_view(template_name=template_name), name='login'),
    

    See the authentication views documentation for more details.

提交回复
热议问题