当我尝试使用Django的内置密码重置系统时。它不考虑我的模板。此外,当我单击重置密码按钮时,它会将我带到Django admin重置页面(
photo
).
我的
the file map
我的URL。py:-
from django.conf.urls import url
from django.contrib.auth import views as auth_views
from . import views
app_name = 'accounts'
urlpatterns = [
url(r"^login/$", auth_views.LoginView.as_view(template_name = "accounts/login.html"),name='login'),
url(r"^logout/$", auth_views.LogoutView.as_view(template_name='thanks.html'), name="logout"),
url(r"^signup/$", views.SignUpView, name="signup"),
url(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',views.activate, name='activate'),
url(r'^password_reset/$', auth_views.PasswordResetView.as_view(template_name='registration/password_reset_form.html'), name='password_reset'),
url(r'^password_reset/done/$', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
url(r'^reset/done/$', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'),
]
模板:-
password\u reset\u表单。html
{% extends 'reg_base.html' %}
{% load bootstrap3 %}
{% block body_block %}
<h3 class="display-1">Forgot password</h3>
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
<button class="btn btn-primary" type="submit">Submit</button>
</form>
{% endblock %}
密码\u重置\u确认。html
{% extends 'reg_base.html' %}
{% load bootstrap3 %}
{% block body_block %}
{% if validlink %}
<h3 class="display-2 text-center">Change password</h3>
<form class="form-control" method="post">
{% csrf_token %}
{% bootstrap_form form %}
<button class="btn btn-default" type="submit">Change password</button>
</form>
{% else %}
<p class="lead">
The password reset link was invalid, possibly because it has already been used.
Please request a new password reset.
</p>
{% endif %}
{% endblock %}
已安装的应用程序
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap3',
'accounts',
]
主URL。py公司
from django.conf.urls import url, include
from django.contrib import admin
from . import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$',views.HomepageView.as_view(),name='home'),
url(r'^accounts/', include("accounts.urls")),
url(r'^accounts/', include("django.contrib.auth.urls")),
]