Adding forgot-password feature to Django admin site

Viet picture Viet · Feb 16, 2010 · Viewed 8k times · Source

How to add the forgot-password feature to Django admin site? With email/security question options? Is there any plug-in/extension available?

Answer

Lakshman Prasad picture Lakshman Prasad · Feb 16, 2010

They are all there built in the django. Just add the relevant url patterns. As follows.

from django.contrib.auth import views as auth_views

patterns+=('',
url(r'^passreset/$',auth_views.password_reset,name='forgot_password1'),
url(r'^passresetdone/$',auth_views.password_reset_done,name='forgot_password2'),
url(r'^passresetconfirm/(?P<uidb36>[-\w]+)/(?P<token>[-\w]+)/$',auth_views.password_reset_confirm,name='forgot_password3'),
url(r'^passresetcomplete/$',auth_views.password_reset_complete,name='forgot_password4'),
)

And, oh, while you are at it, also add the views and url patterns for password change.

url(r'^password/change/$',
   auth_views.password_change,
   name='auth_password_change'),
url(r'^password/change/done/$',
   auth_views.password_change_done,
   name='auth_password_change_done'),

They are listed in the documentation of course.

You'll have to provide your own templates.