简体   繁体   中英

python custom password hasher error

hye . i cannot import my new custom password hasher and i still cannot figure it out why .

the error :

ImportError at /admin/

No module named 'honeywordHasher.hashers.MyHoneywordHasherdjango'; 'honeywordHasher.hashers' is not a package

i already did install honeywordHasher in INSTALLED_APPS and i have the init .py inside the honeywordHasher file.

directory :

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',
]

i already create hashers.py and also the honeyword generation in honeywordgen.py . i still get this error . can someone help me ?

You have missed out the comma after your custom hasher. It should be:

'honeywordHasher.hashers.MyHoneywordHasher',

Without the comma, Python concatenates the string with the one on the next line to form 'honeywordHasher.hashers.MyHoneywordHasherdjango.contrib.auth.hashers.PBKDF2PasswordHasher' , which causes the import error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM