If you forgot your django admin/superuser password, there are multiple ways to reset it. We will go over them. If you lost your username, then we will find that back again as well.
Find your username #
If you already have your username, then skip to this part. On your server or localhost, start django shell:
Up next, we can find out what usernames are used for admins with this:
If you have changed the
username field, then please change it above as well to whatever default username field is.
You will now get a result similar to this:
If you get multiple results, you have multiple superusers. Pick the one that you want to change the password from.
Reset your Django admin password #
Open up Django shell if you haven’t yet (
python manage.py shell). Then copy/paste this:
That’s the function we will use to change the password of a user. Up next, you can simply do:
Obviously, change the username with the username of your superuser account and change the password with something you want to use as a password.
Please note that if you do not have the
username field as the username, then change it in the function above. Specifically, change this:
To this (if you use email as the username):
Let me know in the comments below if you still need help with resetting your Django admin password.