pythondjangopassword-hashhoneypotdjango-custom-user

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 ?


Solution

  • 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.