错误:
ImportError at /admin/
No module named 'honeywordHasher.hashers.MyHoneywordHasherdjango'; 'honeywordHasher.hashers' is not a package
我已经在INSTALLED_APPS中安装了honeywordHasher,并且我在honeywordHasher文件中有 init .py。
目录:
C:.
├───checkout
│ ├───migrations
│ │ └───__pycache__
│ ├───templates
│ └───__pycache__
├───contact
│ ├───migrations
│ │ └───__pycache__
│ ├───templates
│ └───__pycache__
├───custom_user
│ ├───migrations
│ │ └───__pycache__
│ └───__pycache__
├───honeywordHasher
│ ├───migrations
│ │ └───__pycache__
│ └───__pycache__
├───profiles
│ ├───migrations
│ │ └───__pycache__
│ ├───templates
│ │ └───accounts
│ └───__pycache__
├───register
│ ├───migrations
│ ├───templates
│ │ └───accounts
│ └───__pycache__
├───sqlite
├───tryFOUR
│ └───__pycache__
└───__pycache__
settings.py:
PASSWORD_HASHERS = [
'honeywordHasher.hashers.MyHoneywordHasher'
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
]
我已经创建了hashers.py以及honeywordgen.py中的honeyword生成。我仍然得到这个错误。有人能帮助我吗?
答案 0 :(得分:2)
您的自定义哈希后错过了逗号。它应该是:
'honeywordHasher.hashers.MyHoneywordHasher',
没有逗号,Python concatenates字符串与下一行的字符串形成'honeywordHasher.hashers.MyHoneywordHasherdjango.contrib.auth.hashers.PBKDF2PasswordHasher'
,这会导致导入错误。