[Answer]-Django non persistent model field

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

Leave a comment