Найти - Пользователи
Полная версия: django-registration user забыл пароль
Начало » Django » django-registration user забыл пароль
1
django314
А что можно сделать, в случае, если user забыл пароль. Регистрация производилась с помощью приложений django-registration.
pythonlove
Можно заставить пользователя придумать новый пароль. В django.contrib.auth.views для этого имеются следующие вьюхи:

password_reset
password_reset_done
password_reset_confirm
password_reset_complete

Посмотрите, что они делают. Можно прикрутить их, куда посчитаете нужным. Весьма вероятно, что для них вам захочется написать свои темплейты, но это будет несложно.
django314
Дайте, пожалуйста, ссылку на полную документацию или учебник.

Я даже не совсем понимаю в чем проблема
http://127.0.0.1:8000/accounts/password/reset/
NoReverseMatch at /accounts/password/reset/
Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

http://127.0.0.1:8000/accounts/password/reset/34
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/password/reset/34
Using the URLconf defined in univ.urls, Django tried these URL patterns, in this order:
accounts/register/$ [name='registration_register']
^accounts/ ^activate/complete/$ [name='registration_activation_complete']
^accounts/ ^activate/(?P<activation_key>\w+)/$ [name='registration_activate']
^accounts/ ^register/$ [name='registration_register']
^accounts/ ^register/complete/$ [name='registration_complete']
^accounts/ ^register/closed/$ [name='registration_disallowed']
^accounts/ ^login/$ [name='auth_login']
^accounts/ ^logout/$ [name='auth_logout']
^accounts/ ^password/change/$ [name='auth_password_change']
^accounts/ ^password/change/done/$ [name='auth_password_change_done']
^accounts/ ^password/reset/$ [name='auth_password_reset']
^accounts/ ^password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$ [name='auth_password_reset_confirm']
^accounts/ ^password/reset/complete/$ [name='auth_password_reset_complete']
^accounts/ ^password/reset/done/$ [name='auth_password_reset_done']
Singularity
django314
не правильно url подключены.
Кажется должны быть include как с admin.
django314
Singularity
django314не правильно url подключены. Кажется должны быть include как с admin.

У меня accounts именно include-ом подгружен:
url(r'^accounts/', include('registration.backends.default.urls')),

при этом login, logout, register …. работают.
Singularity
я не знаю но
^accounts/ ^login/$
это неправильно
pythonlove
Все становится гораздо понятнее, если просто заглянуть в код. Вот что происходит в password_reset:

    if post_reset_redirect is None:
        post_reset_redirect = reverse('password_reset_done')

Видно, что там возникает такая ситуация, в которой требуется урл с именем ‘password_reset_done’, а у вас вместо него - урл с именем ‘auth_password_reset_done’, благодаря тому, что нужные вам вьюхи подключены через django-registration. Зачем там к именам урлов добавляется префикс ‘auth_’, я не знаю. Возможно, когда-то так и нужно было делать, но с тех пор что-то изменилось.

Посмотрите, что происходит здесь и попробуйте сделать то же самое, только include('registration.auth_urls') замените на include('auth.urls').
slav0nic
django-registration без хакомв не работает с мажорными версиями джанги
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB