Forgot Django admin password? Reset it on the command line.

Wednesday 28 January, 2009 at 8:26 pm / 1 comment - Cole Whitelaw

Just a quick post. Was just rerouting some of my django stuff so I can hang a test site that I was working on from a new domain and realised that I’d forgotten my admin password doh!

So instead of farting around hashing a replacement and putting it in the database I thought I’d have a go on the python command line, so here it is:



>>> from django.contrib.auth.models import User

# Grab all users and output
>>> userlist = User.objects.all()
>>> userlist
[< User:yourusername >]

# Refer to your required user by index and set new password
>>> userlist[0].set_password('newpasswd')

# Then save it
>>> userlist[0].save()

All done!

One Comment


Trackbacks and Pingbacks

Leave a Comment


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>