首页 > 解决方案 > 如何在 django 中更改默认模板身份验证登录这不起作用?

问题描述

如何在 django 中更改默认模板身份验证登录这不起作用?

urlpatterns = [ path('',views.registration,name='registration'),
path('login/',auth_views.LoginView.as_view(template_name='login.html'),),

标签: djangotemplatesauthenticationdefault

解决方案


它不起作用,因为您错误地传递了模板。

应用程序文件夹应如下所示:

App_name/templates/App_name/login.html

如果您的 App_name 是用户,它将是这样的:

path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),


推荐阅读