Implementing a Forgot Password Feature on a Django Site

Here is something that seems to be quite common on any type of membership site – members forget their password.

This morning I was about to write this and I though surely there must be something build in. Surely.

It’s turns out it is built in quite nicely and very easy to use. Start with a simple link on your template:

<a href="{% url django.contrib.auth.views.password_reset %}">Forgot your password?</a>

Then, create the following five templates:


Note that you don’t even need to create these templates for the feature to work. If you don’t create them you will see the forms using the default Django admin template. Obviously you’ll want to create them and extend your base template.

If you get a NoReverseMatch error, add the following line to your main file:

url(r'^account/', include('django.contrib.auth.urls')),

Check out the auth built in views docs for more info.