0
0
Djangoframework~20 mins

Password change and reset in Django - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Password Reset Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens after a successful password change using Django's built-in PasswordChangeView?
When a user submits a valid form to Django's PasswordChangeView, what is the default behavior of the view?
AThe user is redirected to the URL specified by <code>success_url</code> or <code>settings.PASSWORD_CHANGE_REDIRECT_URL</code>.
BThe user is logged out automatically and redirected to the login page.
CThe password is changed but the user stays on the same page with a success message.
DThe user receives an email with a confirmation link to activate the new password.
Attempts:
2 left
💡 Hint
Think about what Django does after a form is successfully processed in a class-based view.
📝 Syntax
intermediate
2:00remaining
Which code snippet correctly sets up Django's PasswordResetConfirmView URL pattern?
You want to add a URL pattern for PasswordResetConfirmView in your urls.py. Which option is correct?
Apath('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm')
Bpath('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView, name='password_reset_confirm')
Cpath('reset/<uid>/<token>/', auth_views.PasswordResetConfirmView(), name='password_reset_confirm')
Dpath('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view, name='password_reset_confirm')
Attempts:
2 left
💡 Hint
Remember how Django class-based views are added to URL patterns.
state_output
advanced
2:00remaining
What is the state of the user session after password reset confirmation?
After a user successfully confirms their password reset via PasswordResetConfirmView, what happens to their session state?
AThe user is automatically logged in and the session is authenticated.
BThe user remains logged out and must log in manually after resetting the password.
CThe session is cleared and the user is redirected to the password reset complete page.
DThe user session is preserved but marked as unauthenticated.
Attempts:
2 left
💡 Hint
Consider Django's default behavior for password reset confirmation regarding authentication.
🔧 Debug
advanced
2:00remaining
Why does this password reset email fail to send?
You use Django's PasswordResetView but no email is sent. The code is:
auth_views.PasswordResetView.as_view(email_template_name='registration/password_reset_email.html')

What is the most likely cause?
AThe user email is missing from the form data, so no email is sent.
BThe <code>email_template_name</code> argument is invalid and causes a silent failure.
CThe <code>EMAIL_BACKEND</code> setting is not configured or uses console backend only.
DThe <code>PasswordResetView</code> requires a custom form class to send emails.
Attempts:
2 left
💡 Hint
Check your Django email settings when emails don't send.
🧠 Conceptual
expert
3:00remaining
Which statement about Django's password reset token is true?
Regarding the token used in Django's password reset process, which option is correct?
AThe token is a random UUID stored in the session during the reset process.
BThe token is a permanent string stored in the database linked to the user.
CThe token is generated from the user's password hash and never expires.
DThe token is a time-limited hash that becomes invalid after a password change or after a set timeout.
Attempts:
2 left
💡 Hint
Think about how Django ensures password reset tokens are secure and expire.