1
我正在使用Django的內置重置密碼視圖與自定義模板。雖然它可以成功運行,但如果提交的電子郵件ID尚未在網站中註冊,則它不會顯示錯誤消息。Django重置密碼不捕獲無效電子郵件ID
我按照說明here來幫助我達到這一點。
#urls.py
url(r'^users/password/reset/$',
'django.contrib.auth.views.password_reset',
{'post_reset_redirect' : '/users/password/reset/done/'},
name="reset_password"
),
url(r'^users/password/reset/done/$',
'django.contrib.auth.views.password_reset_done'
),
url(r'^users/password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
'django.contrib.auth.views.password_reset_confirm',
{'post_reset_redirect' : '/users/password/done/'}
),
url(r'^users/password/done/$',
'django.contrib.auth.views.password_reset_complete'
),
無論電子郵件ID,我給,Django的總是重定向我/用戶/密碼/ RESET /做/它說:
We've e-mailed you instructions for setting your password to the e-mail address
you submitted.
You should be receiving it shortly.
這是一種誤解,因爲用戶可能已經進入了他們的電子郵件地址錯誤,仍然在看上面的頁面。
如果電子郵件地址未註冊,如何顯示錯誤消息?
在此先感謝。
哦..我已經在使用django-allauth進行Facebook登錄。我不知道他們也提供了重置密碼功能。如何連接網址以使用django-allauth?他們沒有很好的文檔。非常感謝您的幫助:) – Amit 2014-10-01 15:54:48
嘗試訪問http:// localhost:8000/accounts/password/reset /(對於localhost) – cdvv7788 2014-10-01 15:57:56
要更改模板,只需覆蓋模板/帳戶/目錄中需要的任何內容(在這種情況下與密碼重置有關的那些):https://github.com/pennersr/django-allauth/tree/master/allauth/templates/account – cdvv7788 2014-10-01 16:01:25