> ## Content Index
> Fetch the complete content index at: https://djangowaves.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to reset the Django admin and superuser password
- URL: https://djangowaves.com/how-to-reset-the-django-admin-and-superuser-password/
- Published: 2019-11-18T23:00:00.000Z
- Updated: 2026-08-13T00:54:10.000Z
- Author: Stan Triepels
- Tags: Django, admin, password, tips-tricks

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 scroll to the next part. On your server or localhost, start Django shell:

```
python manage.py shell
```

Up next, we can find out what usernames are used for admins with this:

```python
from django.contrib.auth import get_user_model
list(get_user_model().objects.filter(is_superuser=True).values_list('username', flat=True))

```

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:

```python
['hello@djangowaves.com']
```

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:

```python
from django.contrib.auth import get_user_model
def reset_password(u, password):
    try:
        user = get_user_model().objects.get(username=u)
    except:
        return "User could not be found"
    user.set_password(password)
    user.save()
    return "Password has been changed successfully"

```

That's the function we will use to change the password of a user. Up next, you can simply do:

```python
reset_password(username, password)
# example: reset_password('hello@djangowaves.com', 'averysecretpassword')
```

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:

```python
user = get_user_model().objects.get(username=u)
```

To this (if you use email as the username):

```python
user = get_user_model().objects.get(email=u)
```

Let me know in the comments below if you still need help with resetting your Django admin password.