擅长:python、mysql、java
<p>有一个<a href="https://docs.djangoproject.com/en/3.0/topics/auth/passwords/#password-upgrading-without-requiring-a-login" rel="nofollow noreferrer">entire section in the documentation</a>关于使用/升级不同哈希程序的帐户。在开始迁移旧密码字段或不是由Django创建的密码字段时需要做更多的工作</p>
<p>看起来您接受了一个答案,该答案将普通的hexdigest存储在password字段中,没有crypt方法标识符,因此我假设您的旧数据库不是Django的,因为Django将在hexdigest前面加上<code>sha1$</code></p>
<p>如果您的数据库确实是一个旧的Django数据库,那么很可能只需更改settings.py中的密码哈希器即可:</p>
<pre class="lang-py prettyprint-override"><code>PASSWORD_HASHERS = [
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher', # Or, if even older:
'django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher',
]
</code></pre>