'Set a password with the raw password string, or the pre-hashed password.
If using the raw string,'

def set_password(self, raw_password=None, hashed_password=None, cached_password=None):

    assert ((hashed_password is None) or settings.DEBUG), 'Only    use    hashed_password    in    debug    mode.'
    assert ((raw_password is not None) or (hashed_password is not None)), 'Must    be    passing    in    raw    or    hashed    password'
    assert (not ((raw_password is not None) and (hashed_password is not None))), 'Must    be    specifying    only    one--not    both.'
    if raw_password:
        verify_raw_password(raw_password)
    if hashed_password:
        self.password = hashed_password
        CachedPassword.invalidate_cached_password(user=self)
    else:
        n_iters = (settings.PASSWORD_ITERATIONS_TEACHER_SYNCED if self.is_teacher else settings.PASSWORD_ITERATIONS_STUDENT_SYNCED)
        self.password = crypt(raw_password, iterations=n_iters)
        if self.id:
            CachedPassword.set_cached_password(self, raw_password)
