如何解决django:密码更改模板定制
我想在django中更改密码更改模板,但我不能。 django正在看到django / contrib / admin / templates / registration /模板版本,而不是我精心制作的myapp / templates / registration / password * .html
urls.py
from django.contrib.auth.views import PasswordChangeDoneView,PasswordChangeView
urlpatterns = [
path('password_change/',PasswordChangeView.as_view(),name='password_change'),path('password_change/done/',PasswordChangeDoneView.as_view(),name='password_change_done'),]
setting.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates','Dirs': [os.path.join(BASE_DIR,'templates')],'APP_Dirs': True,'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},]
解决方法
您可以在auth视图中传递模板名称:
from django.contrib.auth.views import PasswordChangeDoneView,PasswordChangeView
urlpatterns = [
path('password_change/',PasswordChangeView.as_view(template_name="myapp/templates/registration/templatename.html"),name='password_change'),path('password_change/done/',PasswordChangeDoneView.as_view(template_name="myapp/templates/registration/templatename.html"),name='password_change_done'),]
来源:https://ccbv.co.uk/projects/Django/3.0/django.contrib.auth.views/PasswordChangeView/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。