1π
β
To answer your question as-is, you can grab a reference to the password before you set it:
self.temp_pw = user.generate_password()
user.set_password(self.temp_pw)
And then you have access to the password as self.temp_pw but it will be a volatile property, not one that gets saved to the db.
HOWEVER, I would strongly recommend against doing this and particularly against sending passwords by email. It is far better to provide a password reset feature, IMO.
π€dylrei
Source:stackexchange.com