Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django set_password not working

I set the user password and it checks out, but I can't login in various login forms. I can't authenticate:

u = User.objects.get(username='foobar')
u.set_password('123')
u.save()
u.check_password('123')  # True
authenticate(username='foobar', password='123')  # None?!?!

I can't log the user in though I've tried various ways.

like image 212
Skylar Saveland Avatar asked Jan 24 '26 02:01

Skylar Saveland


1 Answers

Make sure that the user is_active. If the user does not have the .is_active flag set to True, it can lead to unusual behavior. Maybe your user got accidentally shadow banned :D

like image 98
Skylar Saveland Avatar answered Jan 26 '26 19:01

Skylar Saveland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!