I'm trying to use the Django authentication system, but I'm getting the error: enter image description here
'user' is an app name.
Project's urls.py:
from django.conf.urls import url, include
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
...
url(r'^user/', include('user.urls', namespace='user')),
...
]
user/urls.py:
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^register/$', views.register, name='register'),
url(r'^settings/$', views.settings, name='settings'),
url(r'^settings/password/$', views.password, name='password'),
url(r'^settings/accounts/$', views.configure_accounts,
name='configure_accounts'),
url(r'^settings/accounts/error/$', views.configure_accounts_error,
name='configure_accounts_error'),
url('^', include('django.contrib.auth.urls')),
]
I can access /user/login/, /user/logout/. When I go to /user/password_reset/, I can enter email, and, after pressing 'Submit' button, an error occurs (shown at picture):
NoReverseMatch at /user/password_reset/
Reverse for 'password_reset_done' not found. 'password_reset_done' is not a valid view function or pattern name.
Any ideas how to fix this? Thanks a lot.
url(r'^password_reset/$', auth_views.password_reset, {
'post_reset_redirect': '/user/password_reset/done/'
}, name='password_reset'),
url(r'^password_reset/done/$', auth_views.password_reset_done,
name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
auth_views.password_reset_confirm, {
'post_reset_redirect': '/user/reset/done/'
}, name='password_reset_confirm'),
url(r'^reset/done/$', auth_views.password_reset_complete,
name='password_reset_complete'),
I set 'post_reset_redirect' in user/urls.py , and everything started to work properly. And after submitting email on reset page, nothing was displayed in console, because of this:
If the email address provided does not exist in the system, this view won’t send an email, but the user won’t receive any error message either. This prevents information leaking to potential attackers.