2012-11-15 52 views
1

我創建一個新用戶,並指定該用戶的密碼:如何讓新用戶重置密碼?

user = User(username = username, email = email) 
user.set_unusable_password() 
user.save() 

當這個新用戶嘗試重置密碼,他們得到一個錯誤:

The user account associated with this e-mail address cannot reset the password

回答

2

set_unusable_password設置一個值,永遠不會是一個有效的密碼哈希,並使用戶自己的密碼不可更改。

我想你應該生成一個複雜的密碼(使用make_random_password)併發送一個用於重置密碼的鏈接給用戶。

+0

Thanx,你幫了很大忙! – inoks