41👍
✅
set_password
only creates a hashed password; it doesn’t save the value in the database. Call save()
to actually save it.
In your views, it should be
user.save()
below the line
user.set_password(user.password)
You didn’t write the brackets (parentheses). That’s why save
method is not being called after you hash the password.
2👍
answer update 25 july 2021
set_password method working django version 3.2
custom singup django 3.2
make sure the variable not passing null. for development you can make print before pass to set_password method.
def user_register(request):
if (request.method == 'POST'):
username = request.POST.get('username')
password = request.POST.get('password')
print(password, type(password))
#make sure the password not passed null
user = User.objects.create_user(
email=email,
name=username,
password=password,
)
user.set_password(password)
user.save()
how you test with django shell.
python manage.py shell
here list django shell commands
from .models import user_type, User
user = User.objects.create_user(email="ll55@gmail.com",password="uU123456",name="le5")
user.set_password("uU123456")
user.save()
u = User.objects.get(name="as6")
u.name
u.password
- Django + celery – How do I set up a crontab schedule for celery in my django app?
- Django bulk create objects from QuerySet
Source:stackexchange.com