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

前端 未结 2 1646
执念已碎
执念已碎 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.

    0 讨论(0)
  • 2020-12-21 01:22

    You are using the unreleased master branch of Django, which has removed the old function-based login view. You should use the released version 1.11, where they are still present (but deprecated).

    The latest master of DRF has removed this reference, but you should stick with released versions anyway.

    0 讨论(0)
提交回复
热议问题