def bcrypt_check_password(self, raw_password):
pwd_ok = False<EOL>should_change = False<EOL>if self.password.startswith('<STR_LIT>'):<EOL><INDENT>salt_and_hash = self.password[<NUM_LIT:3>:]<EOL>pwd_ok = bcrypt.hashpw(smart_str(raw_password), salt_and_hash) == salt_and_hash<EOL>if pwd_ok:<EOL><INDENT>rounds = int(salt_and_hash.split('<STR_LIT:$>')[<NUM_LIT:2>])<EOL>should_change = rounds != get_rounds()<EOL><DEDENT><DEDENT>elif _check_password(self, raw_password):<EOL><INDENT>pwd_ok = True<EOL>should_change = True<EOL><DEDENT>if pwd_ok and should_change and is_enabled() and migrate_to_bcrypt():<EOL><INDENT>self.set_password(raw_password)<EOL>salt_and_hash = self.password[<NUM_LIT:3>:]<EOL>assert bcrypt.hashpw(raw_password, salt_and_hash) == salt_and_hash<EOL>self.save()<EOL><DEDENT>return pwd_ok<EOL>
Returns a boolean of whether the *raw_password* was correct.

Attempts to validate with bcrypt, but falls back to Django's
``User.check_password()`` if the hash is incorrect.

If ``BCRYPT_MIGRATE`` is set, attempts to convert sha1 password to bcrypt
or converts between different bcrypt rounds values.

.. note::

    In case of a password migration this method calls ``User.save()`` to
    persist the changes.