This site runs best with JavaScript enabled.

How to Reset a Django Admin Password

The most efficient way to change your admin password on a Django site.

How to Reset a Django Admin Password How to Reset a Django Admin Password

Photo by Mr TT on Unsplash

This is just a quick post to give a tip on how to recover or reset your Django admin username and/or password.

Use your django shell to query the User model.

python manage.py shell
from django.contrib.auth.models import User

If you can't remember your username, you can view all users in the system.

for u in User.objects.all(): print u.username

Once you know your username, you can simply reset the password:

u = User.objects.get(username='dustin')
u.set_password('secret') u.save()

Discuss on 𝕏 Edit post on GitHub