Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

djang2.0内置登录方法等,已经不用login,loginout #6

Open
liuchangfu opened this issue Nov 23, 2018 · 1 comment
Open

djang2.0内置登录方法等,已经不用login,loginout #6

liuchangfu opened this issue Nov 23, 2018 · 1 comment

Comments

@liuchangfu
Copy link

path('login/', auth_views.login, name='user_login'),
path('new-login/', auth_views.login, {'template_name': 'account/login.html'}, name='user_login'),
path('logout/', auth_views.logout, {'template_name': 'account/logout.html'}, name='user_logout'),
path('register/', views.register, name='user_register'),
path('password-change/', auth_views.password_change, {"post_change_redirect":"/account/password-change-done", 'template_name': 'account/password_change_form.html'}, name='password_change'),
path('password-change-done/', auth_views.password_change_done, {'template_name': 'account/password_change_done.html'}, name='password_change_done'),
path('password-reset/', auth_views.password_reset, {"template_name":"account/password_reset_form.html", "email_template_name":"account/password_reset_email.html", "subject_template_name":"account/password_reset_subject.txt", "post_reset_redirect":"/account/password-reset-done"}, name="password_reset"),
path('password-reset-done/', auth_views.password_reset_done, {"template_name":"account/password_reset_done.html"}, name="password_reset_done"),
path('password-reset-confirm///', auth_views.password_reset_confirm, {"template_name":"account/password_reset_confirm.html", "post_reset_redirect":"/account/password-reset-complete"}, name="password_reset_confirm"),
path('password-reset-complete/', auth_views.password_reset_complete, {"template_name":"account/password_reset_complete.html"}, name="password_reset_complete"),

上述代码中的内置方法,已经在django2.0不适用了,代码需修改,从以下模块中导入内置方法
from django.contrib.auth.views import LoginView
url中需修改为以下代码
path('login/', LoginView.as_view(), name='user_login'), # django内置登录
path('new-login/', LoginView.as_view(), {'template_name': 'account/login.html'}, name='user_login'),

@liuchangfu liuchangfu changed the title djang2.0内置登录方法等,已经不用login(),loginout djang2.0内置登录方法等,已经不用login,loginout Nov 23, 2018
@qiwsir
Copy link
Owner

qiwsir commented Nov 26, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants