Password Reset using a URL with token

63 views
Skip to first unread message

Anil Mor

unread,
Aug 15, 2017, 12:42:09 AM8/15/17
to Django users
Hi,
I am facing an issue while implementing the password reset functionality. 
This is the error that I am facing, don't know where I am wrong.

NoReverseMatch at /music/password_reset/

Reverse for 'password_reset_done' not found. 'password_reset_done' is not a valid view function or pattern name.
Request Method:GET
Request URL:http://127.0.0.1:8000/music/password_reset/
Django Version:1.11.3
Exception Type:NoReverseMatch
Exception Value:
Reverse for 'password_reset_done' not found. 'password_reset_done' is not a valid view function or pattern name.
Exception Location:C:\Python27\lib\site-packages\django-1.11.3-py2.7.egg\django\urls\resolvers.py in _reverse_with_prefix, line 497
Python Executable:C:\Python27\python.exe
Python Version:2.7.13
Python Path:
['C:\\Users\\anil\\Desktop\\ProjectD\\hyWeb',
 'C:\\Users\\anil\\Desktop\\ProjectD\\hyWeb',
 'C:\\WINDOWS\\SYSTEM32\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages',
 'C:\\Python27\\lib\\site-packages\\django-1.11.3-py2.7.egg',
 'C:\\Python27\\lib\\site-packages\\pytz-2017.2-py2.7.egg']
Server time:Tue, 15 Aug 2017 04:33:56 +0000

Below is the code of music.urls. Music is the name of my app


from django.conf.urls import url

from . import views
from django.contrib.auth import views as auth_views
from django.contrib.auth.views import password_reset,password_reset_done,password_reset_confirm,password_reset_complete
from django.contrib.auth.views import PasswordResetDoneView,PasswordResetView,PasswordResetCompleteView,PasswordResetConfirmView
app_name = 'music'

urlpatterns = [

url(r'^login/$', views.LoginFormView.as_view(), name='login'),
url(r'^signup/$', views.signupFormView.as_view(), name='logout'),
url(r'^ChangePassword/$',views.changePasswordView.as_view(), name="ChangePassword"),


url(r'^password_reset/$', auth_views.password_reset, name='password_reset'),
url(r'^password_reset/done/$', auth_views.password_reset_done, 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.password_reset_confirm, name='password_reset_confirm'),
url(r'^reset/done/$', auth_views.password_reset_complete, name='password_reset_complete'),

]


This is the settings.py
"""
Django settings for hyWeb project.

Generated by 'django-admin startproject' using Django 1.11.3.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '8jv!-_1g=h-))wzuwvg-v4clwl4g#&^+lox$=!=!1kno79^@g+'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'music.apps.MusicConfig',
'hyUsers.apps.HyusersConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

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',
]

ROOT_URLCONF = 'hyWeb.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'hyWeb.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/1.11/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/1.11/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/1.11/howto/static-files/
STATIC_URL = '/static/'

#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'


EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'my_google_email_address'
EMAIL_HOST_PASSWORD = 'Password'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER




Reply all
Reply to author
Forward
0 new messages