(user)
return True
Send a user an email with a new, auto-generated password.

    We cannot decrypt the current password stored with the user record,
    so create a new one, and send it to the user.

    This method is used within the forgotpassword form endpoint, but not
    as a user facing view.

    Parameters:
        user -- The django user whose password will be changed.

    Returns:
        True if the user was modified and notified successfully.
Send a user an email with a new, auto-generated password.
Send a user an email with a new auto - generated password .
def emailpassword(user):
    """
    Send a user an email with a new, auto-generated password.

    We cannot decrypt the current password stored with the user record,
    so create a new one, and send it to the user.

    This method is used within the forgotpassword form endpoint, but not
    as a user facing view.

    Parameters:
        user -- The django user whose password will be changed.

    Returns:
        True if the user was modified and notified successfully.
    """

    newpw = ''.join([
        choice(
            'abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNOPQRSTUVWXYZ023456789!@#$%^&*()-_=+'
        ) for i in range(8)
    ])
    context = {'user': user, 'new_password': newpw}
    template = loader.get_template('forgottenpassword.email')

    try:
        s = sha1()
        s.update(newpw)
        user.set_password(s.hexdigest())
        user.save()
    except:
        return False

    send_mail(
        _('Your Password Reset Request'),
        template.render(context),
        settings.EMAIL_HOST_USER, [user.email],
        fail_silently=False)
    return True
def emailpassword ( user ) : newpw = '' . join ( [ choice ( 'abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNOPQRSTUVWXYZ023456789!@#$%^&*()-_=+' ) for i in range ( 8 ) ] ) context = { 'user' : user , 'new_password' : newpw } template = loader . get_template ( 'forgottenpassword.email' ) try : s = sha1 ( ) s . update ( newpw ) user . set_password ( s . hexdigest ( ) ) user . save ( ) except : return False send_mail ( _ ( 'Your Password Reset Request' ) , template . render ( context ) , settings . EMAIL_HOST_USER , [ user . email ] , fail_silently = False ) return True