Get or Reset Django Admin Password in Python

As a developer, while working on a Django project, I forgot the admin password. At first, I thought there would be a simple way to “see” the password, but I quickly realized that Django stores passwords in a hashed format for security.

So, you can’t directly view the admin password. But the good news is, you can easily reset it using a few different methods.

In this tutorial, I’ll show you the exact steps I use when I forget my Django admin password.
I’ll cover three quick methods: using the Django shell, using changepassword, and creating a new superuser.

Method 1 – Reset Password Using Django Shell

The easiest way I’ve found is through the Django shell.
Here’s what I usually do:

  1. Open your terminal in the project directory.
  2. Run the following command:
python manage.py shell
  1. Inside the shell, run this code:
from django.contrib.auth.models import User

# Replace 'admin' with your actual username
user = User.objects.get(username='admin')
user.set_password('NewSecurePassword123!')
user.save()

print("Password reset successfully!")
  1. Exit the shell and log in with the new password.

You can refer to the screenshot below to see the output:

django default admin password

This method works great when you remember the username but forgot the password.

Method 2 – Use the changepassword Command

Another quick way is to use the built-in changepassword management command.

Here’s how I do it:

python manage.py changepassword admin
  • Replace admin with your username.
  • It will ask you to type and confirm the new password.

You can refer to the screenshot below to see the output:

how to know django admin username and password

This is my go-to method when I want a simple and direct reset without writing code.

Method 3 – Create a New Superuser

Sometimes, you may not even remember the username. In that case, I simply create a new superuser.

Run this command:

python manage.py createsuperuser

It will ask you for:

You can refer to the screenshot below to see the output:

django admin password

Once created, you can log in with the new account.
Later, you can go to Django Admin → Users and reset the password for the original account.

Method 4 – Reset All Admin Passwords with a Script

If you’re working on a team project and multiple admin users have lost access, you can reset passwords in bulk.

Here’s a Python script I use inside the Django shell:

from django.contrib.auth.models import User

# Reset all superuser passwords to the same temporary one
for user in User.objects.filter(is_superuser=True):
    user.set_password('TempPassword2025!')
    user.save()
    print(f"Password reset for {user.username}")

After this, all superusers can log in with the temporary password and then change it from the admin panel.

Note

Since Django stores passwords in hashed format, there’s no way to retrieve the old password.
You can only reset it.

This is a good thing; it keeps your project secure.
So, if you ever forget the password, just reset it using one of the methods above.

Conclusion

You can reset it through the Django shell, use the changepassword command, or even create a new superuser if needed. I prefer the shell method because it’s quick and works every time.
But if you’re just starting, the changepassword command is the most beginner-friendly option.

No matter which method you use, you’ll be back in your Django admin panel within minutes.
And remember, Django never lets you “see” the old password for security reasons, so resetting is always the way to go.

You may also like to read other Django tutorials:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.