I created admin user and added some other users to build an authentication form login form. I then loged out the ADMIN and tried to login but i forgot the password. I need to reset my admin password . Could you plz help me how to figure it out.
Open a shell instance:
python manage.py shell
Grab your User
my_user = YourUserModel.objects.filter(email="firstname.lastname@example.org").first() my_user.set_password("NewPassword") my_user.save()
There’s a management command
changepassword that allows you to reset any password from the command line.
I run this code and it says “NameError: name ‘YourUserModel’ is not defined”
It says changepassword is not recognised.
Please provide the exact command line you used to try running it, along with the complete error message that was returned.
This is the complete code u run.
You would run this command as
python manage.py changepassword. See the docs at the top of that page.
Thank you sir. I resolved the error. You are right i should type python instead of py.