Howto Reset The Admin Password in Django
keep needing to do this, darn it! I leave a project for a few months, possibly push it live, and then I go back to fire up the dev server but I simply cannot remember the password I used for admin during development. Why don’t I use my stupid-development-password? I don’t know, but this seems to happen with some regularity. Luckily, it is trivial to fix with a few lines at the python commandline:
Deep:/opt/webapps/invisible bruce$ ./manage.py shell Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) Type "copyright", "credits" or "license" for more information. IPython 0.7.2 -- An enhanced Interactive Python. ? -> Introduction to IPython's features. %magic -> Information about IPython's 'magic' % functions. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In : from django.contrib.auth.models import User In : users = User.objects.all() In : users Out: [<User: admin>] In : users.set_password('whatever'); In : users.save()
That’s it, fire up the dev server again and your new password will get you in.