Skip to content

Resetting Django Admin Password

2008 August 7
tags:
by pk

This barely qualifies for a blog post, but what to do if you loaded, via django-admin.py loaddata
a full json file from someone during testing, and don’t have their user’s password?

Just run the django-admin.py shell, and by hand reset all the passwords:

from django.contrib.auth.models import User
for u in Users:
u.set_password(‘secret’)
u.save()

That’s why you have to keep your shell login and settings files safe !!

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Posterous
  • Tumblr
  • Twitter
4 Responses leave one →
  1. August 10, 2008

    If you’re using Django Command Extensions (http://code.google.com/p/django-command-extensions/) you can just use the passwd management command.

  2. max permalink
    November 18, 2010

    Might work, but so far I notice that I need to pip

    django-extensions

    due to a name change.

  3. December 6, 2011

    Good advise from stackoverflow:

    python manage.py createsuperuser

    You will be asked for login/password of new account with superuser privileges. Then you can login with given credentials and do anything you want via admin interface.

  4. PK permalink*
    December 6, 2011

    Igor,

    Yes the new createsuperuser django admin command is the way to go. This post was written many years ago when that was not available!

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS