Как перенаправить ссылку входа в систему в password_reset_complete Django - PullRequest
2 голосов
/ 23 мая 2019

Ссылка на логин в password_reset_complete направляет пользователя к аккаунту / логину, а не к аккаунту / логину. Как мне это решить?

Ошибка:

Using the URLconf defined in tutorial.urls, Django tried these URL patterns, in this order:
[name='login_redirect']
admin/
account/
The current path, accounts/login/, didn't match any of these.

счета / urls.py:

urlpatterns = [

path('', views.home, name="home"),
path('login/', LoginView.as_view(template_name='accounts/login.html'), name='login'),
path('logout/', LogoutView.as_view(template_name='accounts/logout.html'), name='logout'),
path('register/', views.register, name='register'),
path('profile/', views.view_profile, name='profile'),
path('profile/edit/', views.edit_profile, name='profile-edit'),
path('change-password/', views.change_password, name='change-password'),
path('reset-password/', PasswordResetView.as_view(), name='reset-password'),
path('reset-password/done/', PasswordResetDoneView.as_view(), name='password_reset_done'),
path('reset-password/confirm/<uidb64>/<token>/',
         PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
path('reset-password/complete/', PasswordResetCompleteView.as_view(), name='password_reset_complete'),

основной / urls.py:

urlpatterns = [
path(r'', views.login_redirect, name='login_redirect'),
path('admin/', admin.site.urls),
path('account/', include('accounts.urls')),

]

settings.py:

LOGIN_REDIRECT_URL = '/account/'

Спасибо

1 Ответ

1 голос
/ 23 мая 2019

Похоже, что вы определили неверный шаблон URL

urlpatterns = [
    path(r'', views.login_redirect, name='login_redirect'),
    path('admin/', admin.site.urls),
    <b>path('accounts/', include('accounts.urls')), # use "accounts" instead of "account"</b>
]

Примечание

Теперь все ваши /account/.. URL-адреса будут изменены на /accounts/...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...