Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Handling Password Reset Emails

00:00 Handling Password Reset Emails. As seen previously, each password reset email sent by Django contains a link that can be used to reset the password. To handle that link correctly, Django needs two more templates: password_reset_confirm to display the actual password reset form and password_reset_complete to show a confirmation that a password was reset.

00:28 These will look very similar to the password change templates. Let’s start with the form.

00:54 Just like before, Django will automatically provide a form, but this time it will be a password reset form. You’ll also need a confirmation template.

01:34 If you now follow the password reset link from one of the emails, you should see a form similar to the one seen on-screen. You can now check if it works. Insert a new password into the form, click Confirm, log out, and log in using that new password.

01:51 You can change the default templates for Django emails just like any other user management related templates. password_reset_email determines the body of the email, and password_reset_subject determines the subject of the email.

02:08 Django provides a wide range of variables in the email template context that you can use to compose your own messages.

02:44 You can also change the subject to something more descriptive by altering the file seen on-screen. If you implement these changes and send a password reset email again, then you should see this reflected in a terminal showing the email content.

03:08 As you can see, both the subject and content of the email have changed. Now that you have the features set up to allow users to manage their own passwords, in the next section, you’ll take a look at how to set your site up to allow users to register.

Avatar image for kevinponcepk

kevinponcepk on July 23, 2022

Hey please. My problem are the ‘Subject:’ of my email is ” Password reset on 127.0.0.1:8000”.

I try many think but I don’t…

Sorry for my English man I’m French people and my English are so bad.

But I want to work hard for upgrade this languague skills.

Thanks

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on July 25, 2022

@kevinponcepk Can you give us more details, please? Perhaps you could share your code via a link to your GitHub repository or GitHub gist?

Avatar image for stehnacheric

stehnacheric on Nov. 18, 2022

Hello, I am having a weird issue with the password reset form. I am able to add the password reset link, have it send to my terminal and get to the link but the actual form seems broken. The issue is that I can only type into the confirm email field and the new password field has no input. I have a screen shot if that helps I can add it to the slack channel if you need more info.

Thanks, Eric

Avatar image for slk slk

slk slk on Jan. 7, 2024

When I click the link that I recieve to reset the passsword, it just shows the confirm button. No textfields to type my new password.

Avatar image for Darren Jones

Darren Jones RP Team on Jan. 9, 2024

@slk slk - First thing, I would check your code on the page, as often there can be small typos (which take a few checks to find!) which are causing this kind of issue. You can check your code against the sample code, and that usually helps (it does for me, anyway!)

Become a Member to join the conversation.