11 July 2013

What to do when you forgot the Django admin password on OpenShift

So, you created a django app on OpenShift, added some changes, push the changes, ... and forgot to note the admin password!

What to do next?

It's actually quite easy:
  1. ssh into your application
  2. start the virtual env:
    source $OPENSHIFT_HOMEDIR/python/virtenv/bin/activate
    
  3. change to the app dir:
    cd $OPENSHIFT_HOMEDIR/app-root/repo/wsgi/openshift/
    
  4. open the django shell:
    python manage.py shell
  5. Reset the password:
    from django.contrib.auth.models import User
    u=User.objects.get(username__exact=’admin’)
    u.set_password(‘whatever’);
    u.save()
    
And that's it. Have fun!
comments powered by Disqus