mcottondesign

Loving Open-Souce One Anonymous Function at a Time.

How to reset Django admin password

Sometimes you just can't remember what you set it to, or like me, you restore from an SQL file that you never knew the password for. Anyway, python to the rescue.

> python manage.py shell


from django.contrib.auth.models import User

u = User.objects.all()
u=User.objects.get(username__exact=’admin’)
u.set_password(‘whatever’);
u.save()

thanks to http://coderseye.com/2007/howto-reset-the-admin-password-in-django.html and the first comment