Thursday 3 January 2019

Django: Change password for postgres database user

Start the shell using the command

python manage.py shell_plus

Print all the users using

users=User.objects.all()
print(users)

Get the specific user for which password has to be changed


user=User.objects.get(email='')
 
in the '' write the email for the user
OR we can get the user by username
 
user=User.objects.get(username='') 

Here username has to be written in the ''

Set the new password for the user
 
user.set_password('1234qwer')

We have changed the password for the user. The new password is 
1234qwer