I am trying to do a password reset in django (2.1.1) but i keep getting the following error when i import password reset:
ImportError: cannot import name 'password_reset'
Thsis is my import:
from django.contrib.auth import (
authenticate,
get_user_model,
login,
logout,
password_reset,
password_reset_done
)
The password_reset
view, etc. function-based views have been rewritten to class-based views: the PasswordResetView
[Django-doc] class in django-1.11, as is specified in the release notes. These function-based views could still be used, but were deprecated.
As of django-2.1, the function-based views have been removed, as specified in the release notes.
You can write it like:
from django.contrib.auth.views import PasswordResetView
from django.urls import path
urlpatterns = [
path(
'accounts/password_reset/',
PasswordResetView.as_view(),
name='password_reset'
),
]
of course you might want to change the URL, the view name, and pass parameters to the as_view
to tailor the PasswordResetView
to your specific use case.
Note that, as specified in the release notes, other related views have been removed as well, like password_change
, password_change_done
, password_reset_done
, password_reset_confirm
, and password_reset_complete
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With