Mischback / django-project-skeleton

A skeleton aka. template for Django projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

bolerap opened this issue · comments

commented

Hi @Mischback
I got this error AttributeError: module 'django.contrib.auth.views' has no attribute 'login' when run python manage.py runserver

ENV: django 2.1.1

commented

This seem deprecated in django 2.x I've tried to make it work by create a folder called registration inside root_project/templates and copy login.html from root_project/templates/core to root_project/templates/registration. And change root url conf by path('accounts/', include('django.contrib.auth.urls')). Now login and logout works via url /accounts/login, /accounts/logout. What do you think about it?

Thanks, it worked for me :)

Getting same error AttributeError: module 'django.contrib.auth.views' has no attribute 'login' when run python manage.py runserver

ENV: django 2.1.3

Getting same error AttributeError: module 'django.contrib.auth.views' has no attribute 'login' when run python manage.py runserver

ENV: django 3.7

commented

from django.contrib.auth.views import LoginView
path('login/', LoginView.as_view(), name='login'),

from django.contrib.auth.views import LoginView
path('login/', LoginView.as_view(), name='login'),

It worked. Thank you. 4 days ago, omg I'm so lucky.

from django.contrib.auth.views import LoginView
path('login/', LoginView.as_view(), name='login'),

from django.contrib.auth.views import LoginView
ImportError: cannot import name 'LoginView'

from django.contrib.auth.views import LoginView, LogoutView
path('accounts/login/', LoginView.as_view(), name='login'),
path('accounts/logout/', LogoutView.as_view(), name='logout'),
this is logging me out of the admin interface

path('accounts/logout/', LogoutView.as_view(), name='logout'),
@satvikkaul please have you been able to rectify the error?

If no then go to your settings.py file and add the following to the last line of the file
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
Hope this helps.

Thanks a lot @Johntover

Thanks guys. it worked for me

from django.contrib.auth.views import LoginView
path('login/', LoginView.as_view(), name='login'),

with this code error solved but when I run the server it not show Username and Password field in Browser. so please guide me.

Hello

Hello Vaiishalipatel, You need to create a template for the login page before it will be displayed. If you have already created the login page, then give us more details so that we can help you out. Thank you.

On Thu, Nov 28, 2019 at 7:22 PM Vaiishalipatel @.***> wrote: from django.contrib.auth.views import LoginView path('login/', LoginView.as_view(), name='login'), with this code error solved but when I run the server it not show Username and Password field in Browser. so please guide me. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#3?email_source=notifications&email_token=ALNSGP4F4LWVQVYV2TZL4ZTQWAK6PA5CNFSM4FTIJPM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFNKHVA#issuecomment-559588308>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALNSGP6P5CFGWQF7OKUO2QDQWAK6PANCNFSM4FTIJPMQ .

Hello John,
There is error in login template and now it solved.
Thank you so much.

How is this solved using function based generic views

This issue is fixed in 1.4.
Please refer to 1.4 and the stable documentation to see a compatibility list (this repo's versions vs. Django versions).

1.4 should support Django 2.2 (which is a LTS release) and 3.0 (which is the most recent one). Please note, that tox.ini and Makefile were modified to ease the development, but are currently not usable to manage a project, that was created using this repository.

thanks @johntovor you made my day