I know most of all have fallen prey to setting a ridiculously hard password to our admin panels, saving them somewhere and loosing the password due to forgetfulness, or one of the other many reasons we lose our passwords.
This happened to me while working through a Django tutorial and I just want to document how I was able to solve it.
1) Access your python shell using:
python manage.py shell
This little code snippet will bring up your python shell development.
2) Next thing we will do is to get the lists of users and this can by done by:
a: Import Users from Django auth:
from django.contrib.auth.models import User
b: Assign Users objects to a variable and print it:
users = User.objects.all() print users
This prints out the total users in your application, and you can select which is your admin. Generally though, the admin user is often always the first user created.
3) Select the ‘id’ of the admin user:
user = users
4) Set a new password for the user:
5) Save the new password: