login() got an unexpected keyword argument 'template_name'

1,871 views
Skip to first unread message

Yonggang Dai

unread,
Oct 10, 2018, 10:38:05 PM10/10/18
to django...@googlegroups.com
HI! I am having issues with django login . I want to use the default  login class with the html file "login.html". But  I meet the below issue.
Please  help me to fix it. Thanks  a lot.

image.png

Daniel Bojorge (Foros)

unread,
Oct 13, 2018, 9:27:08 AM10/13/18
to Django users
I suggest you that you use path in the url file.  I made an implemantation of login like this

from django.urls import include, path
from django.contrib.auth import views as auth_views

from generales.views import Home, SinPrivilegios, HomeSinPrivilegios

urlpatterns = [
    path('', Home.as_view(), name='home'),
    path('login/', auth_views.LoginView.as_view(template_name='generales/login.html'), name='login'),
    path('logout/', auth_views.LogoutView.as_view
         (template_name='generales/login.html'), name='logout'),
    path('sin_privilegios/', HomeSinPrivilegios.as_view(), name='sin_privilegios')
    
]

How you can see, just import the auth views (wiht aliases) and just put in parameter the name of the template_name.  And work for me.

All this (and more) I covered in my course about Django 2.1, https://goo.gl/oeT5Sx    Take a look.  It is in spanish, but may be I can help you if you register.
Reply all
Reply to author
Forward
0 new messages