无法在 Django 管理面板创建用户

Unable to create a user at django admin panel

嗯,我不太确定这个问题是否普遍存在。当我尝试从 django 的管理面板添加用户时,我收到以下错误:

The module in NAME could not be imported: django.contrib.main.password_validation.UserAttributeSimilarityValidator. Check your AUTH_PASSWORD_VALIDATORS setting

从错误正文中我了解到:

Exception Value:    
The module in NAME could not be imported: django.contrib.main.password_validation.UserAttributeSimilarityValidator. Check your AUTH_PASSWORD_VALIDATORS setting.
Exception Location: C:\Users\Dmitriy\PycharmProjects\FileTime\venv\lib\site-packages\django\contrib\auth\password_validation.py, line 29, in get_password_validators

主要问题是那个文件 (password_validation.py) 的第 (29) 行没有关于 'get_password_validators' 的内容。有趣的是我可以从命令行创建一个用户。

那么,我该怎么做才能解决这个问题呢?

来自文档:https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#enabling-password-validation

我看到这个验证器位于 django.contrib.auth.password_validation.UserAttributeSimilarityValidator 但从错误中我看到你输入了:django.contrib.main.password_validation.UserAttributeSimilarityValidator

请打开settings.py并设置:

AUTH_PASSWORD_VALIDATORS = [
{
    'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},