Skip to content

Instantly share code, notes, and snippets.

@tenomoto
Last active December 23, 2018 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenomoto/07cd0de2e4cacfb7edfcbdd19a3b0b12 to your computer and use it in GitHub Desktop.
Save tenomoto/07cd0de2e4cacfb7edfcbdd19a3b0b12 to your computer and use it in GitHub Desktop.
add password reset to django admin
# use console backend for development
# https://docs.djangoproject.com/en/2.1/ref/settings/#std:setting-EMAIL_BACKEND
# https://docs.djangoproject.com/en/2.1/topics/email/#django.core.mail.backends.smtp.EmailBackend
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# use admin site to login
# https://docs.djangoproject.com/en/2.1/ref/settings/#std:setting-LOGIN_URL
LOGIN_URL = '/admin/'
# https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#adding-a-password-reset-feature
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
path(
'admin/password_reset/',
auth_views.PasswordResetView.as_view(),
name='admin_password_reset',
),
path(
'admin/password_reset/done/',
auth_views.PasswordResetDoneView.as_view(),
name='password_reset_done',
),
path(
'reset/<uidb64>/<token>/',
auth_views.PasswordResetConfirmView.as_view(),
name='password_reset_confirm',
),
path(
'reset/done/',
auth_views.PasswordResetCompleteView.as_view(),
name='password_reset_complete',
),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment