How to store Django hashed password without the User object?
The accepted answer was helpful to me - I just wanted to add the check_password call (for people like me, who haven't used this functionality before)
from django.contrib.auth.hashers import make_password, check_passwordhashed_pwd = make_password("plain_text")check_password("plain_text",hashed_pwd) # returns True
You are on the right track. However you can manage the password manually using
from django.contrib.auth.hashers import make_passwordprint "Hashed password is:", make_password("plain_text")
Hasher configuration will be driven by PASSWORD_HASHERS which should be common for both the auth system and your UserActivation model. However you can pass it in make_password
method also.
PASSWORD_HASHERS = ( 'myproject.hashers.MyPBKDF2PasswordHasher', 'django.contrib.auth.hashers.PBKDF2PasswordHasher', 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher', 'django.contrib.auth.hashers.BCryptSHA256PasswordHasher', 'django.contrib.auth.hashers.BCryptPasswordHasher', 'django.contrib.auth.hashers.SHA1PasswordHasher', 'django.contrib.auth.hashers.MD5PasswordHasher', 'django.contrib.auth.hashers.CryptPasswordHasher',)
Hope this helps.
Read this link for more details: https://docs.djangoproject.com/en/dev/topics/auth/passwords/
I solved it recently by doing the following steps:
from .models import Clientfrom django.contrib.auth.hashers import make_passwordfrom .forms import ClientFormform = ClientForm(request.POST)if form.is_valid(): first_name = form.cleaned_data['first_name'] family_name = form.cleaned_data['family_name'] password = make_password(form.cleaned_data['password']) phone = form.cleaned_data['phone'] user = Client(first_name=first_name, family_name=family_name, password=password, phone=phone) user.save()