I am using this example to create a custom User model. I want to test this through django shell.
When I create a user from django shell using MyUser.objects.create(email='[email protected]', data_of_birth=datetime.date.today(), password='somepassword'), the password doesn't get hashed and is stored in the database as plaintext.
But if I create a user through django admin portal, it gets stored as a hash.
What do I need to do so that it gets stored as hash even through shell? Do I need to implement some function of my own?
Django version 1.7.3
Use User.set_password():
user = MyUser(email='[email protected]'), ...)
user.set_password('somepassword')
user.save()
staff = Staff()
staff.username = username
staff.set_password(password)
staff.save()
here staff is inherited model from USER , when user enter password you just give to the set_password , django automaticaly converted into hasble pwd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With