I'm using the django built-in function to reset the password in case the user forgot his password.
I also created my own Html pages to make the appearance look good.
password_reset_form.html, password_reset_done.html, password_reset_confirm.html, password_reset_complete.html, and password_reset_email.html for the email.
- the name of password_reset_form.html in my URL is "reset_password"\
- the name of password_reset_done.html in my URL is "password_reset_done"\
- the name of password_reset_confirm.html in my URL is "password_reset_done"\
- the name of password_reset_complete.html in my URL is "password_reset_complete"
reset_password and password_reset_done django inbuilt templates work well with my html page created.
The problem apprears When I clicked on the link sent to my e-mail, I should see back to my browser my custom url page (password_reset_confirm.html) but instead i'm seeing the django built in template ("password reset confirmation").
I don't know where is the mistake. I have been trying to set that for 2 days now, but it's difficult to figure it out.
Can you please help me out?
here is my setting:
"""
Django settings for grouppublishingindia project.
Generated by 'django-admin startproject' using Django 3.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATE_DIR = os.path.join(BASE_DIR,'templates')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '5r0zcv0wdd2yhow_t)k)xj$c(3mnkqiww_yr0w7k+i+ii36)5v'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Inventory',
'crispy_forms',
'debug_toolbar',
'import_export',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware'
]
CRISPY_TEMPLATE_PACK = "bootstrap4"
ROOT_URLCONF = 'grouppublishingindia.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'Inventory', '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',
],
},
},
]
WSGI_APPLICATION = 'grouppublishingindia.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
LOGIN_REDIRECT_URL = "contenu"
#SMTP (Simple Mail Transfert Protcole) Configuration
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = '*******************'
EMAIL_HOST_PASSWORD = '***************'
here is my project URLs:
from django.urls import path, include
from django.contrib.auth import views as auth_views
from django.conf.urls import url
from django.contrib import admin
from django.conf import settings
from Inventory import views
urlpatterns = [
path('admin/', admin.site.urls),
path("",include("Inventory.urls")),
url('Inventory/',include('django.contrib.auth.urls')),
]
here is my app URLs:
from django.contrib.auth import views as auth_views
from django.urls import reverse
from django.conf.urls import url
from .views import *
from Inventory import views
from .views import index
from Inventory.views import SearchResultsView
from django.urls import path
app_name = "Inventory"
urlpatterns =[
path('password_reset/', auth_views.PasswordResetView.as_view(template_name='Inventory/password_reset_form.html',
success_url=reverse_lazy('Inventory:password_reset_done')),name="reset_password"
),
path('password_reset/done/',
auth_views.PasswordResetDoneView.as_view(template_name='Inventory/password_reset_done.html'), name="password_reset_done"
),
path('password_reset_confirm/<uidb64>/<token>/',
auth_views.PasswordResetConfirmView.as_view(template_name='Inventory/password_reset_confirm.html'),
name="password_reset_confirm"
),
path('reset_password_complete/',
auth_views.PasswordResetCompleteView.as_view(template_name='Inventory/password_reset_complete.html'),
name="password_reset_complete"
),
]
password_reset_confirm
topassword_reset_confirmation
. becuase thepassword_reset_comfirm
might be used as name for django's built-in url. – Ajay Lingayat